Regardless of the rotation of the cube, by pressing the button, the cube should rotate to the face.
Example:
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class CubeDoTweenController : MonoBehaviour
{
private Quaternion targetRotation;
private void Awake()
{
targetRotation = transform.rotation;
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.D))
{
targetRotation *= Quaternion.FromToRotation(Vector3.up, Vector3.right);
transform.DORotateQuaternion(targetRotation, 1f);
}
else if (Input.GetKeyDown(KeyCode.W))
{
targetRotation *= Quaternion.FromToRotation(Vector3.up, Vector3.forward);
transform.DORotateQuaternion(targetRotation, 1f);
}
}
}
After a couple of turns, the old cube starts to rotate. Thanks in advance for any help
