playMaker

Author Topic: player jump add force 2d  (Read 990 times)

jon

  • Playmaker Newbie
  • *
  • Posts: 5
player jump add force 2d
« on: May 31, 2017, 02:18:56 PM »
Hello
iam making a jump set but the add force2d practically teleports the player up... I think this has something to do with the image settings iam using pixels per unit 32.

i have to use force2d 9000 and RB gravity scale of 45 to make him fall at a normal speed.

Is there a way to make him do a jump using Key down/button down ? In my previous script i was using axisraw vertical this was wrong he kept jumping with the arrow up pressed...

iam trying to make it work this way but using button down.
Code: [Select]
  public float vertical;
  public float jumpForce;

    void Update()
    {
       vertical = Input.GetAxisRaw("Vertical");
    }
    void FixedUpdate()
    {
        Jump();
    }
//-----------------jump-----------------------------------------
    void Jump(){
        if (grounded && anim.GetLayerWeight(2) == 1){
            rB.velocity = new Vector2(rB.velocity.x, vertical * jumpForce - 3);
            }
        else if (grounded && anim.GetLayerWeight(2) == 0){
            rB.velocity = new Vector2(rB.velocity.x, vertical * jumpForce);
        }
    }