Car/Assets/Scripts/RotateAroundTargetAnim.cs

31 lines
616 B
C#
Raw Permalink Normal View History

2025-01-09 21:04:52 +08:00
using System;
using UnityEngine;
public class RotateAroundTargetAnim : MonoBehaviour
{
public Transform target;
public float rotateSpeed = .1f;
private float triggerTimer;
public float FreeTime = 1;
private void FixedUpdate()
{
if (triggerTimer >= FreeTime)
{
this.transform.RotateAround(target.position, target.up, Time.fixedDeltaTime * rotateSpeed);
}
}
private void Update()
{
if (Input.anyKey)
{
triggerTimer = 0;
}
else
{
triggerTimer += Time.deltaTime;
}
}
}