Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Finding Velocity at point but locally....

Discussion in 'Physics' started by Gibbonuk, Dec 20, 2016.

  1. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi, Im not sure why im finding this so difficult but I am for some reason.
    I have a moving body which can go in all directions and I am trying to find the velocity in the X direction of a POINT on that object.

    I can find the X Velocity of the rigid body by simply doing the following:

    Code (CSharp):
    1. float xVel = transform.InverseTransformDirection(targetObj.GetComponent<Rigidbody>().velocity).x;
    The above works fine, but this doesnt do at a specific point...

    So I have tried so far:
    Code (CSharp):
    1. leftVel = this.GetComponent<Rigidbody> ().GetRelativePointVelocity (leftPos.transform.localPosition).x;
    But leftvel still changes depending on the direction of the rigidBody...

    I have tried using just the GetPointVelocity and then inverseTransformDirection but I get the same problem?

    I have tried the above but also transforming the local leftPos but same problem...

    What am i doing wrong?

    Thanks
     
  2. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Think i have sorted it... it seems looking at .x is wrong, in my case it should be .z