# playMaker

### Author Topic: Limit speed of wheel collider[SOLVED]  (Read 7563 times)

#### uberwolfe

• Junior Playmaker
• Posts: 59
##### Limit speed of wheel collider[SOLVED]
« on: September 05, 2013, 09:15:54 AM »
Hi all. I'm looking for the best way to limit the torque on a wheel collider.

I have a system in place at the moment that works, but it's clunky, primitive and it annoys the hell out of me.

Basically I listen for my vehicle to exceed a pre-defined speed.
When it does, I have a state that simply sets the vehicle's Z velocity to the defined max speed and then returns to the listener state.

This works, but there is a slight jerk visible when the speed is set.

I have played around with the brakeTorque property but I still don't think that is the way to go about it...

What is the best process to limit the speed of a wheel collider?

Thanks as always!
« Last Edit: December 03, 2013, 07:20:46 AM by uberwolfe »

#### redikann

• Full Member
• Posts: 174
##### Re: Limit speed of wheel collider
« Reply #1 on: September 06, 2013, 01:28:33 AM »
I am just gonna shoot off a couple suggestions that you may have tried by now.
Have you looked into using a variable clamp in the math category. That's an easy way to define a min and max for a float or int.
Also you can animate variables with a curve if you need to smooth out sudden transitions.

#### uberwolfe

• Junior Playmaker
• Posts: 59
##### Re: Limit speed of wheel collider
« Reply #2 on: September 06, 2013, 03:23:32 AM »
Hey Redikann, thanks for the suggestions

I don't yet understand how curves work so I'll play with clamping and see what comes of it.

#### uberwolfe

• Junior Playmaker
• Posts: 59
##### Re: Limit speed of wheel collider
« Reply #3 on: September 06, 2013, 09:43:49 AM »
I just can't seem to do it...

My vehicle drives fine but trying to limit the speed correctly is doing my head in.

Below is my spaghetti Vehicle Controller - I'm aware there's probably a few potential problems with this but I plan on refining it once I understand the fundamentals.

This is almost a case where I can see how it's done in code but just can't quite visualise it in a state machine.

« Last Edit: September 06, 2013, 09:50:27 AM by uberwolfe »

#### Lane

• Hero Member
• Posts: 2508
• Mender of the past
##### Re: Limit speed of wheel collider
« Reply #4 on: September 06, 2013, 10:10:12 AM »
Hmm, can't really answer without seeing how the whole thing is setup.

I would think you should be able to scale down the torque input when the speed scales up, but that may affect your steering adversely? I would look into connecting those two and having the throttle push less torque if the speed is at at the maximum, then if your mass is set correctly you can constrain it to be unable to actually push the car any faster due to weight.

This should technically 'happen' naturally, but it would change your acceleration rates and bring up the need of two different types of power - torque and horsepower - so that you could have fast acceleration and a different max speed regardless of the "power" the car has. The above suggestion would be a workaround for that.
« Last Edit: September 06, 2013, 10:12:17 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

#### uberwolfe

• Junior Playmaker
• Posts: 59
##### Re: Limit speed of wheel collider
« Reply #5 on: September 06, 2013, 07:57:53 PM »
Hmm, can't really answer without seeing how the whole thing is setup.

I would think you should be able to scale down the torque input when the speed scales up, but that may affect your steering adversely? I would look into connecting those two and having the throttle push less torque if the speed is at at the maximum, then if your mass is set correctly you can constrain it to be unable to actually push the car any faster due to weight.

This should technically 'happen' naturally, but it would change your acceleration rates and bring up the need of two different types of power - torque and horsepower - so that you could have fast acceleration and a different max speed regardless of the "power" the car has. The above suggestion would be a workaround for that.

Thanks Lane, scaling back the torque depending on speed is pretty much the way I've been trying to do it. I'm not too worried about steering as this controller is mostly for tank-like vehicles, I have a simple rotation-based steering system set up in a different FSM that works well.

The problem I can see doing it this way is it will still need to have some kind of auto-braking system to wipe off any extra speed gained by travelling down slopes etc. But that's something I'll work out when I have the speed limiter working properly!

I'm thinking of a torque system (illustrated below) applied by curves - but I can't work the curves out in Playmaker. Can anyone shed any insight??

« Last Edit: September 07, 2013, 01:59:03 AM by uberwolfe »

#### jeanfabre

• Hero Member
• Posts: 15495
• Official Playmaker Support
##### Re: Limit speed of wheel collider
« Reply #6 on: September 13, 2013, 07:03:07 AM »
Hi,

It's very easy actually, using the "sample curve" action.

I have attached a scene showing exactly your setup.

simply sty in the camera inspector and in the fsm inspector, change the value of the speed property ( drag the "speed" label) and you'll see how the torque value is sampled on the curve.

bye,

Jean

#### uberwolfe

• Junior Playmaker
• Posts: 59
##### Re: Limit speed of wheel collider
« Reply #7 on: September 15, 2013, 12:12:44 AM »
Ah I see... It really is that simple. Thanks as always Jean