Basicly I want to detect what speed a VehicleSeat is indicating / showing. But how do I accomplish this? Is there some kindof formula for calculating it? I am using a bodythrust to push the vehicle for those wondering.

Itâ€™s actually pretty simple, but I didnâ€™t find out about this for a while.

First of all you want to get the Velocity of the seat. Then you want the Magnitude property of this as it will tell you the total speed of the seat.

Iâ€™m pretty sure that this is how it works internally although I could be wrong.

If you think about it, Velocity is a direction. So is a Unit vector which has a Magnitude of one. You can set the velocity to a Unit vector multiplied by a speed which multiplies the Magnitude.

Velocity is a Vec3 value. So what parameter of the Velocity should I check the magnitude on? The X, or Y, or Z. (Or maybe I am not understanding you right?)

Vector3s and Vector2s have a Magnitude property which will calculate the magnitude of that vector.

You can find the distance between two objects using Magnitude. Youâ€™d subtract both positions and get the Magnitude of that vector.

If you want to know how Magnitude is calculated look up Pythagorean distance formula. Itâ€™s the same as (vecA-vecB).Magnitude.

So is it just Velocity.Magnitude?

Yepâ€¦ For example if you print your HumanoidRootPartâ€™s Velocity.Magnitude while walking youâ€™ll see it print your WalkSpeed.

Can Velocity.magnitude ever return negative? For example: the vehicle is going backwards so will Velocity.magnitude return negative?

No, Magnitude cannot return negative. Magnitude doesnâ€™t tell you the direction it only tells you the â€śsizeâ€ť of the vector.

If you want Magnitude to be negative if the player goes backwards you can do this using Dot products (which arenâ€™t actually too difficult to understand).

Edit (for the OP if he needs it or new viewers in the future):

a:Dot(b) will return how far in the direction of a that b travels.

So to get the forward/backward speed only you can do something like this: `speed = vehicleSeat.CFrame.LookVector:Dot(vehicleSeat.Velocity)`

This will return a negative value if the car is traveling backwards and positive if the car is traveling forwards but if the car is traveling perfectly straight left or right (so it isnâ€™t going in the direction itâ€™s facing at all) it will return 0. Aka how far the Velocity is traveling in the direction the seat is facing.

The value returned will be the speed since LookVector is a Unit vector. (If this had a Magnitude of 2 it would be the speed/2, 3 would be speed/3, etc)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.