V
V
vodimak2022-01-15 15:51:59
Unity
vodimak, 2022-01-15 15:51:59

How to make it so that you can fly diagonally?

in short, I'm making a game about a pterodactyl and I have a bug every other time that I can't fly up and to the side at the same time. how to fix it? reposting the question.61e2c3272907c676628231.png61e2c32fa3f47929884110.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nekit Medvedev, 2022-01-17
@NIKROTOS

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 question

Ask a Question

731 491 924 answers to any question