How do i make my character to stop moving while he’s in prone ? It’s a side scroller game and i don’t want him to move left or right when i set him in prone.
I don’t have any expirience with side scrollers, but you could use a boolean that is true when your character is prone and set it to false when it isn’t. Then in your movement input use a branch (if statement) to check wheter that boolean is true or false, if it is false excecute the rest of the movement code and if it is true don’t do anything.
Disable character movement and/or set a bool after your input axis. Branch. If bProne is true, do not allow movement, if bProne is false, allows input from player.
If this is acceptable, please upvote and accept as answer. Good luck.
Which is what I just said…
when I was writing this your answer wans’t here yet, question was posted 0 sec ago
Well first off, don’t answer your own question when it’s still wrong;) Use comments so we can track it better.
The BRANCH needs to happen somewhere else, you need to GET Prone and use that as the condition. I suggest you go over these docs and this wiki as well as a number of other beginner tutorials on youtube and learn a little bit about conditionals and OOP.
Good luck!
Ok, so i’ve done this:
I know something is missing but i don’t really know what. When i’m in prone he’s not moving, that’s ok, but when i get up is still frozen.
I’m new in this thing so yea…
Yup, i edited it XD
your problem is more general than just turning off movement while crouching. you need a solution that allows you to change the controls based on the state of the character. when a character is crouching, they have some things they are allowed to do, which are different than the things they are allowed to do while falling, or swimming, or dying, or being knocked down, or during a cutscene… you need a state machine.
a state machine is just an enum variable that controls the flow of execution with a SwitchOnEnum node. it allows you to make different rules for each state. you can use multiple enums to represent more combinations of states, like using 1 enum for physics states, and another enum for attack states. with a state machine, you can do things like not allowing the character to crouch while falling, or not allowing the character to shoot fireballs while swimming.
in your case, in the crouching move state, letting the input axis MoveUp reach 0 or more, results in setting the move state to standing. in the standing move state, letting MoveUp go below 0 sets the move state to crouching.
for anyone happening here, you may want to set the movement back to walk based on a Notify aptly position at the end of the getting up animation…