#How to implement a Pause/Command logic like in FTL

1 messages · Page 1 of 1 (latest)

granite lily
#

I need a pausing/commanding mode in games like FTL, I do have a grid based movement/targetting etc logic

I do have 2 things in my mind first is abstracting DeltaTime on a system if that system would be paused like Movements

public static class GameTime {
    public static float DeltaTime => GameManager.IsPaused ? 0f : Time.deltaTime;
}

Second is an interface that'll manage each system and call SimTick() if not paused

public interface ISimulatable { void SimTick(float dt); }

what do you guys think is better and why?

carmine jungle
#

I prefer to do #2 where you use your own tick method instead of unity's update and can pass different deltas to it if you want to (including 0, or not calling it at all (which may be slightly different))

#

it also makes it easy to selectively pause certain sections of things by not calling their tick method which you can't do if you're just messing with a global deltatime

gentle ruin
#

You can also just use timescale for the sim stuff and unscaled time for things like time-independent animations, ui, etc. Pause just sets time scale to 0

#

It’s probably the less scalable solution but it’s less work up front

zinc plaza
#

timescale for pausing the game is a terrible idea, it will mess up your physics, animation and tons of things.
instead do it properly by making your own in-game speed/timing

wary creek
#

I would use some inhertiable class or interface for objects/scripts which are pauseable and maybe a subscriber design pattern for hooking up those objects. You may find that not every type of movement uses delta time specifically as an argument, so this is a better approach in that regard

drowsy fern
#

If you manually update some components then it's easy to stop updating when "paused"