unity4.3 rigidbody2d unexpected force behaviour

Posted by Lilz Votca Love on Game Development See other posts from Game Development or by Lilz Votca Love
Published on 2014-05-30T15:16:52Z Indexed on 2014/05/30 16:05 UTC
Read the original article Hit count: 391

Filed under:
|
|
|

So guys ive edited the question and here is what my problem is i have a player which has a rigidbody2d attached to it.my player is able to doublejump in the air nicely and stick to walls when colliding with them and slowly slides to the ground.All movement is handle through physics and no transform manipulations.here i did something similar to this in the FixedUpdate of my player.

    void FixedUpdate()
    {
     if(wall && Input.GetButtonDown("Jump"))
      {
       if(facingright)//player is facing the left side of the wall
        {
         rigidbody2D.Addforce(new vector2(-1f,2f)*jumpforce);
         /*Now the player should jump backwards following this directional vector and
   should follow a smooth curve which in this part works well*/
        }
       else
       {
        rigidbody2D.Addforce(new vector2(1f,2f)*jumpforce);
        /*Now this is where everything gets complicated as you should have noticed
          this is the same directional vector only the opposite x axis value 
        and the same amount of force is used but it behaves like the red curve 
        in the  picture below*/
       }
      }
    }

bad behaviour and vector in red

.I tested the same thing(both addforce methods) for a simple jump and they exactly behave like mentionned above in the picture.so here is my problem.Jumping diagonally forward with rigidbody2d.addforce() do not have the same impact,do not follow the same curve as jumping the opposite direction with the same exact amount of force.if i could fix this or get past this i could implement a walljump system like a ninja jumping in zigzag between two opposite wall to climb them.Any ideas or alternatives?

© Game Development or respective owner

Related posts about 2d

Related posts about unity