Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Rotations : MonoBehaviour {
- public enum RotationMode { Euler, Slerp, LookRotation}
- public RotationMode rotationMode;
- public Quaternion quaternion;
- public float RollZ;
- public float PitchX;
- public float YawY;
- public Transform lookAtSphere;
- void Update()
- {
- RollZ = transform.localRotation.eulerAngles.z;
- YawY = transform.localRotation.eulerAngles.y;
- PitchX = transform.localRotation.eulerAngles.x;
- switch (rotationMode)
- {
- case RotationMode.Euler:
- {
- transform.rotation *= Quaternion.Euler(0, 0, 0.5f);
- quaternion = transform.rotation;
- break;
- }
- case RotationMode.Slerp:
- {
- transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.Euler(0.1f,1.0f,1.0f),2f* Time.deltaTime);
- quaternion = transform.rotation;
- break;
- }
- case RotationMode.LookRotation:
- {
- transform.rotation = Quaternion.LookRotation(transform.position - lookAtSphere.position, Vector3.left);
- quaternion = transform.rotation;
- break;
- }
- default:
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment