Add StickGame Assets
This commit is contained in:
23
phr/StickGame/Assets/Prefabs/VoidTeleport.cs
Normal file
23
phr/StickGame/Assets/Prefabs/VoidTeleport.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
[RequireComponent(typeof(Rigidbody2D))]
|
||||
public class VoidTeleport : MonoBehaviour
|
||||
{
|
||||
public Transform teleportPosition;
|
||||
public float yThreshold = -100;
|
||||
public bool resetVelocity = true;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(transform.position.y < yThreshold)
|
||||
{
|
||||
transform.position = teleportPosition.position;
|
||||
if (resetVelocity)
|
||||
{
|
||||
GetComponent<Rigidbody2D>().velocity = Vector2.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user