L
L
LittleBob2021-10-20 20:47:43
Unity
LittleBob, 2021-10-20 20:47:43

How to implement an "exit" method from a pressed key in Unity?

if (Input.GetKey(KeyCode.D))
While the D key is pressed, a piece of code is executed. Specifically, the object is rotated 45 degrees. I need the object to return the rotation value to 0 when the key is released. How can I do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bogdan Erolskiy, 2021-10-20
@LittleBob

Unity's Input class also has a GetKeyUp function , which is exactly what you want.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question