- Home /
Best way to implement different input modes and states
What is the best way to implement different input modes. For example
Normal mode: user can click on some objects, move map, interact with UI
Build mode: there are several different instruments. Some instruments have different states. For example road building instrument should have states: selecting start point (just waiting for user to click somewhere), selecting second point (showing preview of the road while user moves the mouse).
The most straightforward way is to have enum with all these modes and states and have big switch/case constructions in input handling code. It's not what I want.
Also it is possible to use inheritance and switch different realizations of some interface when game mode changes. That's much better.
But I want to have this behavior realized in different objects. For example while building a road I need to detect collisions between new road segments and road segments that are already on the map. So this code should only work in selecting second point state of building mode, but it's more convenient to have this code in road segment object (just because in Unity collision detection events go to colliding colliders). This particular problem can be solved by using separate class for already built road segments and new ones. But anyway I feel there are better ways for doing things like this.
Your answer
Follow this Question
Related Questions
mac app store build architecture... intel only? 1 Answer
Is it a good idea to use static classes? 0 Answers
Game Won't Build In x86 0 Answers