Files
Crash-Course/Assets/Scripts/TeleportPlatform.cs
TGall8 8543734eb9 Added moving and teleporting platforms in ObstanceWIP. Falling Platform is a WIP
Falling Platforms don't work yet. Still haven't figured out how to make it fall
2025-02-28 17:46:02 -05:00

29 lines
649 B
C#

using UnityEngine;
public class TeleportPlatform : MonoBehaviour
{
public Vector2 teleportPoint;
//public bool teleportPosition = false;
public string teleportTag;
//private void Start()
//{
//if (teleportPosition)
//{
//teleportPoint = transform.position;
//}
//}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag(teleportTag))
{
transform.position = teleportPoint;
if (TryGetComponent<Rigidbody2D>(out var rb))
{
rb.linearVelocity = Vector2.zero;
}
}
}
}