physics2d velocity of 10e-12 when moving!

I see this rigidbody moving and yet its velocity is10e-12 (as seen in the inspector debug infos)!
Does physics2d velocity follow different laws of physics to physx?
how do I get proper velocity?

10e-12 is effectively zero. Why would that be a different law of physics? What is the “proper” velocity?

When I calculate the distance/deltaTime I get around 0.01

This doesn’t really help me help you. Seems you’re inferring that 2D physics is moving a body at 0.01m/s but returning 0.000000000001m/s. I have never seen that and if it were so then we’d have fire and pitchforks as nothing would work.

If you want help then please provide more information rather than giving out little bits of vague information.

2 Likes

You asked for the proper velocity and I gave you the exact velocity - if you know of a way to be less vague than this, do share and in the meantime stop taking out your inability to ask the proper questions on me, I’m not your carpet.

Seems you’re taking offence at me saying you’re being vague. I have no idea what you’re talking about when you say “I’m not your carpet”. Let me be equally candid, nobody is your support either. If you provide more detail on your problem including maybe a snippet of code or detail on the objects in question then it’s much easier and quicker to try to narrow down the issue. You must realise that nobody can help by just saying you’re getting a specific value out of a property.

All you’ve provided on your second post is distance/time which as we all know is velocity. That is indeed vague and won’t help me help you. You must know that.

I think the velocity was calculated wrong because I’m using Move and immediately after, ask for velocity, all that in an Update loop, used to be ok but I think a lot has changed in the physics backend, here is the full setup:

The character is made of a root containing the rigidbody2D and the scripts. The root scale is 1,1,1
Parented to this root is the asset driven by mecanim. I parented collider GO to the asset’s bones. (the colliders are moving with the mecanim driven bones)
The code:

[Task]
    public void WalkToDestination()
    {
        GetComponent<Rigidbody2D> ().MovePosition (transform.position + transform.right * Time.deltaTime * walkSpeed);
        anim.SetFloat("speed", GetComponent<Rigidbody2D> ().velocity);
    }

WalkToDestination is called by PandaBT on each render frame, using Update, not FixedUpdate.

Nothing has changed in the physics backend, using MovePosition doesn’t change the public facing velocity. A long time ago, there was a bug that left the velocity after the move completed but that was a short-lived bug. Beyond that I’m not sure what you mean by something changed; can you ellaborate?

Note that there’s no benefit in calling MovePosition each frame, it won’t move until the next fixed update. Of course, you can continue to update the “target” position doing this but as I say, it won’ t be actioned until the next fixed update.