Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
I don’t understand this language, but usually in this case, they write separate methods for adding along separate axes (in case of pressing buttons), which give out unit vectors. These vectors are passed to the motion script, in which they are added, the result is made unity and it is multiplied by the speed.
That is, the whole movement is not registered in the reaction of pressing the buttons, but in a separate method that receives data from the pressing methods, as a result, different methods do not argue with each other.
By the way, think about what happens if the player presses forward and backward at the same time, or in flight there is nothing to press at all, etc...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question