ZhangZhouSpecialEquipment/Assets/Scripts/叉车/RotateAnimation.cs

30 lines
651 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateAnimation : MonoBehaviour
{
public float rotationSpeed = 50f;
private Vector3 rot;
private void Start()
{
rot = transform.localEulerAngles;
}
void Update()
{
if (Input.GetKey(KeyCode.A))
{
transform.Rotate(-Vector3.up * rotationSpeed * Time.deltaTime);
}
else if (Input.GetKey(KeyCode.D))
{
transform.Rotate(Vector3.up * rotationSpeed * Time.deltaTime);
}
else
{
transform.localEulerAngles = rot;
}
}
}