HeavenStudioPlus/Assets/Scripts/Games/AirRally/CircularMotion.cs
Mytiaoga 2ca9cbbb1d First Contact, Tap Trial, Air Rally
First Contact
- Fixed a bug

Tap Trial
- All anims and input are implemented

Air Rally
- Initialization
2022-07-25 10:04:55 +08:00

27 lines
697 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircularMotion : MonoBehaviour
{
[SerializeField] float timeCounter = 0;
[SerializeField] Transform rootPos;
[SerializeField] float speed;
[SerializeField] float width;
[SerializeField] float height;
private void Start()
{
timeCounter = 0;
}
private void Update()
{
timeCounter += Time.deltaTime * speed;
float x = Mathf.Cos(timeCounter) * width + rootPos.position.x;
float y = Mathf.Sin(timeCounter) * height + rootPos.position.y;
float z = rootPos.position.z;
transform.position = new Vector3(x, y, z);
}
}