Search Unity

AddRelativeForce alternative for rigidbody2d ?

Discussion in '2D' started by greluo, Nov 23, 2013.

  1. greluo

    greluo

    Joined:
    Jan 18, 2013
    Posts:
    4
    hi
    how can i add a relativeForce on a 2d rigidbody, i cant get it to work.
     
  2. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    633
    I was wondering the same thing, unfortanetly it looks like it's not implemented (yet?) as many other Rigidbody functions, but you can use transform.right/up/forward if all you need is simple relative axis movement:
    Code (csharp):
    1.         rigidbody2D.AddForce(new Vector2(transform.right.x*factor,
    2.                              transform.right.y*factor));
    3.  
    That should do it until UT enriches a little bit more Rigidbody2D in upcoming releases.
     
  3. greluo

    greluo

    Joined:
    Jan 18, 2013
    Posts:
    4
    thanks for your help i will test it, but this is not a permanent solution i hope the unity3d devs will implement box2d more with all the joints and all it functionalities.