im pretty new at coding. it supposes to be moving in every angle. its a cube
using UnityEngine;
using System.Collections;
public class rotationTest : MonoBehaviour
{
IEnumerator RotateMe(Vector3 byAngles, float inTime)
{
var fromAngle = transform.rotation;
var toAngle = Quaternion.Euler(transform.eulerAngles + byAngles);
for (var t = 0f; t < 1; t += Time.deltaTime / inTime)
{
transform.rotation = Quaternion.Slerp(fromAngle, toAngle, t);
yield return null;
}
}
void Update()
{
if (Input.GetKeyDown(“d”))
{
StartCoroutine(RotateMe(Vector3.forward * 90, 0.8f));
}
if (Input.GetKeyDown(“a”))
{
StartCoroutine(RotateMe(Vector3.back * -90, 0.8f));
}
if (Input.GetKeyDown(“w”))
{
StartCoroutine(RotateMe(Vector3.right * 90, 0.8f));
}
if (Input.GetKeyDown(“s”))
{
StartCoroutine(RotateMe(Vector3.left * -90, 0.8f));
}
}
}
im new at coding…