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. Dismiss Notice

Question How to add Time.deltaTime

Discussion in 'Editor & General Support' started by garfieldsimp, Jul 14, 2023.

  1. garfieldsimp

    garfieldsimp

    Joined:
    Jul 13, 2023
    Posts:
    3
    When I built my game the speed was slower than in unity after a bit of searching I found out about Time.deltaTime but how ever a try to add it errors start popping up or everything seems fine but when I test it it wont move. This is what I am trying to add it to, do I need to re write this in a different way or am I just missing something small?
    Code (CSharp):
    1. GetComponent<Rigidbody>().AddForce(Vector3.forward, ForceMode.Acceleration);
    oh also its in the void update.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    Physics should be done in FixedUpdate, not Update. Time.deltaTime generally isn't need for physics stuff.
     
  3. garfieldsimp

    garfieldsimp

    Joined:
    Jul 13, 2023
    Posts:
    3
    Thank you that fixed it.