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
This commit is contained in:
28
Assets/Scripts/TeleportPlatform.cs
Normal file
28
Assets/Scripts/TeleportPlatform.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user