Just inquiry about Rigidbody!

i think  that the ball forced to move consistently because of the AddForce method run actually into FixedUpdate , maybe cause if it runs in update , the force of 10 will be multipled by delta time to move consistently between each frame as in transform component if i tried to move on z axis i have to multiply by delta time to make the ball move consistently between each frame as in one second totally, it will move 10 untis  .... or maybe i'm wrong but i need to why and how it's actually moves consistent by only multipled by ten !!!?


  • Jonathan Gonzalez(jgonzalez) replied

    I'm not quite sure I understand what you're asking but I'll see if I can clarify things. Whenever we use physics objects, least in terms of movement using FixedUpdate allows us to move that object at a fixed rate, typically set to .02 seconds. This ensures that objects move smoothly across the screen for everyone who plays the game. Update happens very quickly as well, but is not fixed and may update more times within one second than the next. Which means you'll probably get a stuttering effect when moving physics objects. 

    If you use Time.deltaTime to move an object you're telling it to move at a rate of 1 unit per second, that's why it seems like it's going slow.  If you multiply that by 10, then it'll move 10 times faster. This is not dependent on the frame rate. So if someone is running the game at 60fps vs 120fps they'll still get the same movement speed. Without this (or FixedUpdate) the object may move a lot faster or slower since it will be frame rate dependent. Hope that clears things up a bit. 

  • Boula Azmy(boulagab) replied

    I mean you just typed :

    AddForce(Vector3.Forward * 10), why it's moving smoothly ?!
    If i have 60 frames per second , and update calls every frame so in second 60 frames = 60 * 10 = 600 units ... but it still moves smoothly ?! that's what i am talking about ... is AddForce implemented within FixedUpdate ?

  • Jonathan Gonzalez(jgonzalez) replied

    It can still look smooth in Update, it's the only thing running in game. You can include stuff like this within Update and probably not see issues like we see in the video. The main concern with this is the timing. I didn't use it in this video as I should have, but adding Time.deltaTime ensures that the movement is time dependent on not frame rate dependent. 

    Without that someone could run the game at a higher frame rate and see the object moving at a faster rate since it updates faster. FixedUpdate updates at a fixed interval of .02 seconds, so it acts in a similar way. The physics in game update at that same rate, that's why it's encouraged to use that when moving physics based objects around in game.