Velocity returning 0

So I am trying to spawn a bullet from my player when I click the mouse. Everything is working fine except the velocity.

bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(10, 10);

for some reason the debug is showing the velocity at 0,0 even though literally the line before I am setting it 10,10. Am I missing something about the GetComponent function.

As a side note if I make another script that sets velocity to 10,10 on start and apply it to the bullet prefab it works properly, so the rigidbody is working and there is no collision problems.

You need to specify which component you are getting from your bullet.

// assuming bullet is of type GameObject
bullet.GetComponent<Rigidbody>().velocity = new Vector2 (10, 10);
Debug.Log (bullet.GetComponent<Rigidbody>().velocity);

Is your Rigidbody set as dynamic? Does it have mass? Maybe check those.
Also don’t call GetComponent() twice, it’s relatively slow; Call it once, save it in a variable and use that.

Hello! I’m having the same issue: When i check the speed of a rigidbody on the inspector, in some cases, it’s moving but the speed remains in zero. In some cases it depends of the surface on wich my object is, but in other cases the rigidbody is simply moving but his speed value is zero.