added UFO skywalk animation and bolt car teleport button
This commit is contained in:
29
Assets/_PROJECT/Components/Portals2/Move In Circle.cs
Normal file
29
Assets/_PROJECT/Components/Portals2/Move In Circle.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class MoveInCircle : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float radius = 2f; // Radius of the circular movement
|
||||
[SerializeField] private float speed = 2f; // Speed of circling
|
||||
[SerializeField] private bool clockwise = true; // Direction toggle
|
||||
private float angle = 0f; // Angle for movement
|
||||
|
||||
private Vector3 startLocalPosition;
|
||||
|
||||
void Start()
|
||||
{
|
||||
startLocalPosition = transform.localPosition; // Store the initial local position
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
// Increment angle based on speed and direction
|
||||
angle += (clockwise ? -1 : 1) * speed * Time.deltaTime;
|
||||
|
||||
// Calculate new local position
|
||||
float x = Mathf.Cos(angle) * radius;
|
||||
float z = Mathf.Sin(angle) * radius;
|
||||
|
||||
// Apply the new position relative to the parent
|
||||
transform.localPosition = startLocalPosition + new Vector3(x, 0, z);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user