Best practices for handling pausing the game?

  • July 8, 2017 at 16:14 #21274
    kyle
    Participant

    I am looking for suggestions and best practices for handling when my game is paused. My real goal is to be able to stop a unit immediately and then start him again at the same velocity he stopped with. I’m noticing that my current methods he doesn’t resume at the same speed he was at when he stopped. This makes it look like there is a delay.

    I am currently just setting the preferred speed to 0 and then back to whatever it was when the game resumes from pause.

    gameobject.GetUnitFacade().SetPreferredSpeed(0.0f);

    I have also experimented with .Stop(), .Wait(null), & .Resume(), but they all seemed to have issues. When using .Stop() the unit’s speed would have to accelerate to start. When using .Wait(null) & Resume(), the unit didn’t come to a stop immediately.

    Maybe I am doing something wrong with the approaches above, but I thought it would also be nice to see what people would suggest.

    Thanks in advanced!

    July 14, 2017 at 12:19 #21366
    Geminior
    Keymaster

    We have not explicit support for custom pausing. Pausing by setting the time scale should work.
    However you can easily put this in yourself.

    The class to look at is called SteerableUnitComponent and the method is called Steer(float).
    The easiest modification you can make is to simply have Wait and Resume work the way you describe, and to do that all you need to do is put the following at the start of the Steer method:

You must be logged in to reply to this topic.