How to make the wheels on this car spin?

Me and @nooneisback are trying to make a realistic car that includes: Suspension, driving, steering, etc… But I don’t know how to make the wheels rotate based of the velocity of the vehicle.

The reason I am posting a topic here instead of the building support section is because everything here is scripted. Basically I use scripts to simulate constraints (Other then welds). So for example, The suspension will be done in a script (Not spring constraint), prismatic constraint will be done with a script, etc… But this requires the wheels to be welded to each “Suspension-Thruster”
(There are 4 of them it requires 1 thruster per wheel) So that means that I will have to rotate the wheels by changing the Weld’s C0 or C1 properties. If I change the C0 it wont do anything, if I change the C1 the wheels will act strangely.

Here is the car for those interested:

https://www.roblox.com/library/3329618016/Car

Could I get help on this please?

Basically the chassis in itself is a hovercar with wheels that are scripted to look as if they are touching the ground.

3 Likes

Do the wheels start spinning around like on a stick when you change C1?

1 Like

Maybe try tweening the orientation of the wheels and set repeat in the TweenInfo to true.

2 Likes

That won’t work as the suspension and the wheel rotation is done on the same weld (as far as i remember)

1 Like

Here is what happens when I set the C1:

1 Like

Yep, that’s what I meant. Set the C0 value instead.

C0 = CFrame.Angles(spin,steer,0) + Vector3.new(offset from center) - Vector3.new(0,maxspringlength-distancefromground-wheelradius,0)

A little edit.

2 Likes

What do I set ‘offset from center to’?

1 Like

What are the wheels welded to? The central part or something above them?

2 Likes

The wheels are welded the the thruster above them. For example:

The Back-Left wheel is welded to the Back-Left Thruster.

1 Like

In that case it’s:

C0 = CFrame.Angles(spin,steer,0) - Vector3.new(0,maxspringlength-distancefromground-wheelradius,0)

2 Likes

What is spin, steer supposed to be?

1 Like

Spin is the wheel rotation due to roll, steer is rotation because of steering.

2 Likes

So I can set spin to whatever I want? Can I set steer to the rotvelocity?

The wheel is not rotating yet lol.

1 Like

I mean, I guess. The spin depends on whether the wheel is motorized (the angular velocity doesn’t depend on the ground) or the vehicle’s speed if it’s on ground.

Steer will go from -1 to 1 multiplied by the max angle.

Set them both to 0 until you implement them.

1 Like

I get this error:

10:34:36.356 - Workspace.Car.ServerPhysics:73: bad argument #1 to ‘Angles’ (number expected, got Vector3)

Here is what I am doing:

whdyndata[2].Motor6D.C0 = CFrame.Angles(Car.Chassis.Velocity,Car.Steer.Value,0) - Vector3.new(0,sprlen-dist-whrad,0)

Firstly, you have to store last rotations to offset the rotation from the last rotation.

local newrotation = lastrotations[wheelnum]*Car.Chassis.Velocity.magnitude*dt/wheelradius
whdyndata[2].Motor6D.C0 = CFrame.Angles(newrotation,Car.Steer.Value,0) - Vector3.new(0,sprlen-dist-whrad,0)
lastrotations[wheelnum] = newrotation
1 Like

I will probably just use the system that the roblox jeep uses to position the wheels until I get better at C1’s, C0’s, CFrame.Angles, Etc…

I’m a little confused—if you were working on this together from the getgo, why are you posting on the forum to help each other?

2 Likes

Because I’m not able to use studio for the next half of month.

1 Like