added comments and organized project files

This commit is contained in:
djkellerman
2025-03-28 17:39:07 -04:00
parent 22f44a3f20
commit a098e8c053
84 changed files with 183 additions and 214 deletions

View File

@@ -0,0 +1,30 @@
using UnityEngine;
public class MovingPlatform : MonoBehaviour
{
public Transform platform;
public int startPoint;
public Transform[] points;
public float speed;
private int i;
void Start() // Sets the initial position of the platform
{
transform.position = points[startPoint].position;
}
void Update()
{
// If the platform is close to the target point, it starts moving to the next one
if (Vector2.Distance(transform.position, points[i].position) < 0.02f)
{
i++;
if (i == points.Length)
{
i = 0;
}
}
// Moves the platform towards the next point
transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime);
}
}