I added Speedmeter to my project but it doesnt work. Just stays in 0. I completely new in C#. Project is 2D. Here is code;
public Text text;
private double Speed;
public float speed0 = 0;
void Start()
{
text.text = Speed.ToString();
startingPosition = transform.position;
}
Vector3 startingPosition = Vector3.zero;
void FixedUpdate()
{
speed0 = ((transform.position - startingPosition).magnitude / Time.fixedDeltaTime);
startingPosition = transform.position;
text.text = GetComponent<Rigidbody2D>().velocity.magnitude + " km/h ";
}
