Question by
emirfirat5498 · Apr 29 at 07:32 AM ·
rotationrotategetkeydowngetkeygetkeyup
Regularly rotation control with keys,Regularly Rotation control by keys
I have a question. There is a unit, the rotate character engine. I want to control this with keys, for example, when it is stationary, it returns when the key is pressed. GetKey commands don't work by the way
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Rotate : MonoBehaviour {
public float RotationSpeed = 1f;
private void Start()
{
}
void Update()
{
if (Input.GetKey(KeyCode.I))
transform.Rotate(new Vector3(0f, 1f, 0f).normalized * RotationSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.K))
transform.Rotate(new Vector3(0f, 0f, 0f).normalized * RotationSpeed * Time.deltaTime);
}
},
Comment
Your answer
Follow this Question
Related Questions
GetKeyUp fires on too many frames 3 Answers
GetKeyDown breaks jumping vs GetKey 1 Answer
Check rotation of an obstacle 0 Answers
Rotate Player w/Touch Input Controls 0 Answers
How to rotate an object according to the camera's view? 1 Answer