Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

RigidBody2d.AddForce not working, velocity value in inspector stuck at jumpForce value

Discussion in '2D' started by zRonno, Jul 10, 2020.

  1. zRonno

    zRonno

    Joined:
    Jun 9, 2020
    Posts:
    8
    Code (CSharp):
    1.     void FixedUpdate()
    2.         {
    3.             if (Input.GetKeyDown(KeyCode.Space) | Input.GetKeyDown(KeyCode.W))
    4.                 {
    5.                     rb.AddForce(transform.up * jumpForce, ForceMode2D.Impulse);
    6.                 {
    7.         }
    As the title says, this is not working and I have no clue why/how. The only thing this does is change the GameObject's velocity value to the value of jumpForce, and it never changes back. The GameObject is never affected.
     
  2. zRonno

    zRonno

    Joined:
    Jun 9, 2020
    Posts:
    8
    Well for some reason I had to change all my other movement code to be AddForce. Also realized user input for a single force should be done in Update()