Forum begins after the advertisement:


[Part 22] Rigidbody2D Movement Not on FixedUpdate

Home Forums Video Game Tutorial Series Creating a Rogue-like Shoot-em Up in Unity [Part 22] Rigidbody2D Movement Not on FixedUpdate

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16662
    Sean
    Level 11
    Former Patron
    Helpful?
    Up
    1
    ::

    Hi,

    I added Rigidbody2Ds to my enemies to that they’d collide with each other, instead of overlapping, but they started moving incredibly slow.

    I realised that the Move() function executes Rigidbody2D movement on an Update, not a FixedUpdate. After I changed it so that the Rigidbody2D movement code was executed through a FixedUpdate, it fixed the issue.

    Kind Regards, Sean

    has upvoted this post.
    #16663
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    1
    ::

    Thanks for sharing this Sean. Much appreciated.

      1 anonymous person
    has upvoted this post.
    #16669
    Sean
    Level 11
    Former Patron
    Helpful?
    Up
    1
    ::

    Also, regarding the knockback in the Update function, should this be handled by the rigidbody too if one is present?

    has upvoted this post.
    #16673
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    1
    ::

    Yes. Theoretically speaking, putting it on FixedUpdate() should give you more consistent behaviour, so you should always do that when it is possible.

    I haven’t run into any issues doing it on Update(), but Unity advises that all changes to Rigidbodies should be made on FixedUpdate() as a best practice.

      1 anonymous person
    has upvoted this post.
    #16679
    A_DONUT
    Level 6
    Moderator
    Helpful?
    Up
    0
    ::

    If u have anymore doubts u can ask here I will be glad to help

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: