This might be a noob question, but im making a speed limiter and i want to do this through wheelcollider.rpm. the problem is, wheelcollider.rpm alone gives a value over 1000. I learned somewhere that you need to divide certain numbers to get the speed in mph, or kmh. The thing is, i dont kbow what numbers to divide by. If anyone could list the method to find this out, it would be alot of help
Hi @BloodBTF, if you wanna get you speed on mph or kmh, you should know circumference (L) of your will, to take it you should multiply the radius (R) of you wheel on 2 and PI. For example if radius (R) of your wheel is 1 meter then circumference (L) will L = 2PIR or 23.141 = 6.28 m . Now we know that your wheel is rotate by 1000 rpm. So every rpm you wheel is move on 6.28 m. If now we multiply 6.28 on 1000 we take 6280 meters on minute, or 6.2 km\m or 6.260 = 372 kmh. One mhile is 0.62 kilomiters so to convert kmh to mph just multiply 3720.62=230 mph. So simply code on C# is will be:
public void speedometer(){
float wheelRadius; // put here your wheel radius
int wheelRpm; // put here you rpm
float circumFerence; //here we will store the circumFerence
float speedOnKmh; // here the speed in kilometers in hour
float speedOnMph; // and here the speed in mhiles in hour
circumFerence = 2.0f * 3.14f * wheelRadius; // Finding circumFerence 2 Pi R
speedOnKmh = (circumFerence * WheelRpm)*60; // finding kmh
speedOnMph = speedOnKmh * 0.62f; // converting kmh to mph
}
And don’t forget that in Unity one unit is equl 1 meter, to work physics fine.
(circumFerence * WheelRpm)*60
gives the answer in meters. Divide by 1000 to get Kmh.
But this is not good to show in a speedometer or such cause the values fluctuate wildly! the best way is the get the rigidbody velocity. Do this.
Speedometer.speed = (float)(ds.rb.velocity.magnitude * 3.6)
Thank you So Mutch Guys it was Really helpfull