Y
Y
yuneenk2022-01-21 10:31:15
C++ / C#
yuneenk, 2022-01-21 10:31:15

How to disable keypress on a texture?

Hi all! I have a terrain on which there are different textures, there is a mountain texture and I need to make sure that when the player is on the mountain texture, the space key will be turned off (there is no way to jump).
Can you please tell me how to implement it correctly?
just started a month ago.
fps game.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2022-01-21
@yuneenk

You need to limit it not by textures, but by areas and other logic. Physics and more.

L
LittleBob, 2022-01-21
@LittleBob

You, as you correctly wrote above, do not block the button, but only create conditions.
For example, you can create a boolean variable that you put in the if parameters, and in the if itself there will be a jump code. So it turns out that when you go to the edge of the mountain, this variable returns false and the jump does not work.
The first thing that came to mind was to create and wrap the mountain with a collider cube. When you enter it - false, exit - true. Through the OnTriggerEnter and OnTriggerExit methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question