Search Unity

What are some best Practices to manage states outside of courotines?

Discussion in 'Scripting' started by JuanuMusic, Jun 19, 2020.

  1. JuanuMusic

    JuanuMusic

    Joined:
    Sep 23, 2018
    Posts:
    3
    Hi! I'm an experienced c# developer and most of my knowledge comes from desktop and mobile.
    I'm already familiar with Unity and the Coroutines concept.

    One thing that still has me thinking is the fact of having a Coroutine control the state of an object.
    Let me explain:
    Say I have a helicopter that needs an animation for launching and landing. This would not be tied to any kind of physics, so the only way to know when the animation has finished is to wait for the animation to end.

    Right now I'm setting the launched state of my helicopter at the end of the Launch coroutine that animates my object.

    I can think of a couple of solutions like Callback actions, events, etc but I was wondering if there is any best practice defined for this specific use case.

    Thanks, everyone for your input!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752