Просматривая справку по скриптам, нашел пример:
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public float smooth = 2.0F;
public float tiltAngle = 30.0F;
void Update() {
float tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
float tiltAroundX = Input.GetAxis("Vertical") * tiltAngle;
Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
}
}
using System.Collections;
public class example : MonoBehaviour {
public float smooth = 2.0F;
public float tiltAngle = 30.0F;
void Update() {
float tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
float tiltAroundX = Input.GetAxis("Vertical") * tiltAngle;
Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);
transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
}
}
После поворота на угол tiltAngle кубик разворачивантся в исходное положение, как только отпущу клавишу.
Как можно зафиксировать разворот и, нажимая клавишу, осуществить дальнейший поворот по оси? (проще говоря несколько раз развернуть куб в одном и том же направлении)