My rigidbody.velocity is always 0 after reset

Hello!

I’m trying to rotate my gameobject based on its velocity on the y-axis after zeroing it and applying a new force. But it always returns me 0. What am I doing wrong?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BirdController : MonoBehaviour {

	private bool isDead = false;
	private Rigidbody2D body;

	void Start()
	{
		body = GetComponent<Rigidbody2D>();
	}

	void Update()
	{
		if (isDead == true)
			return;

		if (Input.GetMouseButtonDown(0)) {
			if (GameController.instance.startGame == false) {
				GameController.instance.startGame = true;
				body.simulated = true;
			}

			body.velocity = Vector2.zero;
			body.AddForce(new Vector2(0, 500));

			print (body.velocity.y); // 0 :(

			transform.rotation = Quaternion.Euler (0, 0, body.velocity.y * 3f);
		}
	}

	void OnCollisionEnter2D()
	{
		isDead = true;
	}
}

Calling AddForce() on a RigidBody without specifying a ForceMode (parameter on AddForce()) can lead to continuous velocity-change, which means that the velocity will increase over time, not instantly. If you want to have instant velocity change, check the force modes.

In this case, you could use ForceMode.Impulse or ForceMode.VelocityChange. If it is still not working, you can try to directly change the velocity, however it is not recommended.