What units are used for the axis. (Speed per Second Script included!) ;-)
So I wrote this simple speed script (feel free to use it if you'd like). My question is what am I calculating is the x-axis in meters therefor m/s. If it helps my vehicle is moving at a moderate speed and am averaging around 30 speed per second.
So this is a pretty crude way of detecting speed, but it is accurate enough for what I need. There are a few limitations,..
1) Only going to work for a 2D game and ignores values of why, you could use the same idea with vector3's i suppose.
2) If you do not want negative values for speed you should use math.Abs when calculating.
public class SpeedDetection : MonoBehaviour {
GameObject obj;
float realPos = 0;
float currentPos = 0;
float lastPos = 0;
public float speed;
// Use this for initialization
void Start () {
obj = GameObject.Find ("objName");
InvokeRepeating ("Speed", 1 , Time.deltaTime * 60);
}
void Speed()
{
currentPos = realPos;
speed = currentPos - lastPos;
lastPos = currentPos;
}
// Update is called once per frame
void Update () {
realPos = forkLift.transform.position.x;
}
}
From one x coordinate to the next how much distance is that in real world units?
1ft, m, km, mile?
Answer by Landern · Feb 25, 2016 at 06:04 PM
This concept you need to come up with, some people use 1 meter per unit in Unity, others use different concepts that maybe based off the units in a particular animation/3d modeling software and correlate against Unity's unit system. So in the end, you choose, but make it consistent if the distances over time mean anything to your implementation.
Yea it's not crucial, more curiosity and a guide to how much I'm exaggerating reality in my game
Your answer
Follow this Question
Related Questions
how to calculate speed with in range value. 1 Answer
How can I change Sprite Editor Units to Pixels 0 Answers
Units setup in 3ds max 9 Answers
Placing a rectangle above ad 0 Answers
How set 2D velocity in pixels? 1 Answer