Skip to content

Instantly share code, notes, and snippets.

@partiallyblind
Created February 18, 2022 11:03
Show Gist options
  • Save partiallyblind/02ec959994e58980dc64a77b0d817c25 to your computer and use it in GitHub Desktop.
Save partiallyblind/02ec959994e58980dc64a77b0d817c25 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class TeleportScript : MonoBehaviour
{
void OnEnable()
{
EventManager.OnClicked += Teleport;
}
void OnDisable()
{
EventManager.OnClicked -= Teleport;
}
void Teleport()
{
Vector3 pos = transform.position;
pos.y = Random.Range(1.0f, 3.0f);
transform.position = pos;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment