- Home /
How should I structure my Player code?
Hey, me and a few friends are planning to make a game over the course of about half a year. I'm in charge of coding the player movement and such, and I was wondering if anyone has any tips on what the best way is to structure the code of my player.
The game will be a pretty basic first person shooter, with some light parkouring. The only sophisticated way of coding a character I've really come across is with a Finite State Machine. I was planning on using a Class Based Finite State Machine, but that does seem to be rather complicated and there aren't many videos or articles about it that are understandable for someone who's only ever coded in Unity.
So, two questions really. One, does anyone know an article or video about a Class Based FSM that's written so that less experienced coders can understand it? And two, does anyone know of any other way to code a player that's not just a bunch of if-statements in an update function?
Answer by Artik2442 · Jul 04, 2020 at 04:08 PM
1) I don't know anything about Class Based FSM... So I'll answer only the 2nde question... Sorry.
2) The best way to make character movement without a bunch of if-statements is to use the FPS character Controller with Input.GetAxis("Horizontal") / Input.GetAxis("Vertical")
. It doesn't need lots of if-statements. There is a great tutorial that I used a lot. Hope it helped...
Your answer
