- Home /
Design patter for "interaction/functionality modes"
My game is played with the mouse only. What would be a design pattern or approach for separating "modes" (see examples) so that different interactions don't interfere with each other?
Players would enter a mode by clicking an in-game button, but I'd like switch mode in the editor for testing.
Examples of "modes"
Mode1:
- third person camera
- mouse click to move
- main game UI
Mode 2:
- first person camera
- players can't move
- click to pan camera
- fist person UI
Mode 3
- third person UI
- players can't move
- inventory UI
When you have multiple cases and there are some kind of transitions between them it is usually use a state machine. You need to define the states and transitions between them.
Try to search for State Design Pattern, for example here is a good detail about how it works.
https://gameprogram$$anonymous$$gpatterns.com/state.html
Thank you! This sounds like the right direction, I'll try it.
Answer by Piotrone · Sep 01, 2021 at 07:26 AM
As @simiel7 pointed out, the State Machine Pattern is the way to go. I've also found this video by Jason Weimann that shows a really good implementation of it to control the game flow: https://www.youtube.com/watch?v=V75hgcsCGOM
Your answer
![](https://koobas.hobune.stream/wayback/20220613042252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
iphone and bilinear filtering? 2 Answers
Sphere collision doesn't work when transform is rotated 0 Answers
Reliable / intelligent user input handling 0 Answers
Design pattern of custom animation class 0 Answers
centerOfMass not in edit mode? 2 Answers