CylindricalConstraint Released

Hi Developers!

Recently we released a new constraint: the CylindricalConstraint. You can find the API documentation at:
http://wiki.roblox.com/index.php?title=API:Class/CylindricalConstraint

The cylindrical constraint combines properties of both prismatic and hinge constraint, allowing translation along a line and rotation around an axis. It is equivalent to a prismatic constraint and a hinge constraint with an intermediate part between the two.

In the cylindrical constraint, the axes of rotation and translation don’t have to have the same direction. They can be same, opposite or any angle in between.
Cylindrical

An application of the constraint is in building vehicle suspension where the two axes are perpendicular. The cylindrical constraint simplifies this process: it removes the need for a knuckle - the intermediate part between the wheel and the suspension that often causes instabilities - and the wheel is attached directly to the chassis.
suspension

57 Likes

WOO, this is awesome! Can’t wait to try it out, thank you!

4 Likes

Epic :smiley: really needed something like this.

2 Likes

Will be helpful for ‘Hydraulic’ cylinder applications too where the pivoting component isn’t always inline with the cylinder!

It seems that the CylindricalConstraint wiki page still describes this as a “currently unfinished and unavailable type of constraint”.

3 Likes

Thanks! Will get it fixed

3 Likes

Great job with CCs, they’re really awesome.
I can finally make reliable suspension and tire compression simulations. =D

15 Likes

I think your tires are a little bit underinflated… :thinking:

image

7 Likes

That looks great! How do you simulate the tires?

1 Like

I basically just create a circle of ‘rubber’ blocks around the wheel, connected via a prismatic or, in this case a cylindrical constraint.
The original ‘Wheel’ part then becomes the centre bearing.

Doesn’t really need the cylindrical constraint, but I’m just experimenting.

Here’s the code anyway - just create a part named ‘Wheel’, with a size of about (0.5, 3, 3)

while game.Workspace:FindFirstChild("Wheel",true) do
	local x = 12
	local wheel = game.Workspace:FindFirstChild("Wheel",true)
	wheel.Name = "Wheel_"
	wheel.Anchored = false
	wheel.CanCollide = false
	wheel.CustomPhysicalProperties = PhysicalProperties.new(3*x,2,3,10,100)
	--wheel.CollisionGroupId = 1
	
	local n = 360/x
	for r = 0,360-n, n do
		local rubber = Instance.new("Part",wheel)
		rubber.Size = Vector3.new(wheel.Size.x,wheel.Size.y/(x/1.25),wheel.Size.y/(x/1.25))--wheel.Size * Vector3.new(1.2,0,0) + Vector3.new(0.25,1,1)
		rubber.CustomPhysicalProperties = PhysicalProperties.new(3*x,2,0.3,10,10)
		rubber.Anchored = false
		rubber.CanCollide = true
	--	rubber.CollisionGroupId = 1
		rubber.CFrame = wheel.CFrame * CFrame.Angles(math.rad(90),0,0) * CFrame.new(0,1,0)

		local a0 = Instance.new("Attachment",wheel)
		a0.Orientation = Vector3.new(r,0,90)
		local a1 = Instance.new("Attachment",rubber)
		a1.Orientation = Vector3.new(0,0,90)

		local cConstraint = Instance.new("CylindricalConstraint",wheel)
		cConstraint.ActuatorType = "Motor"
		cConstraint.LimitsEnabled = true
		cConstraint.LowerLimit = 0
		cConstraint.UpperLimit = wheel.Size.Y/2
		cConstraint.MotorMaxForce = 250000/x
		cConstraint.Velocity = 100
		cConstraint.AngularLimitsEnabled = true
		cConstraint.UpperAngle = 0
		cConstraint.LowerAngle = 0
		cConstraint.Restitution = 0.5
		cConstraint.Attachment0 = a0
		cConstraint.Attachment1 = a1
		--cConstraint.AngularActuatorType = "Servo"
		--cConstraint.AngularSpeed = 0
		--cConstraint.ServoMaxTorque = 10000
	end
	wheel.Size = Vector3.new(1,1,1)
end
7 Likes

Cool! Looks good!
Since you have UpperAnge = LowerAngle = 0 you can use the PrismaticConstraint instead for the “spokes”.