Skip to content

Instantly share code, notes, and snippets.

@CSaratakij
Created May 8, 2020 11:17
Show Gist options
  • Save CSaratakij/d91fdbacd7f518177bcd4c5c310a7ecf to your computer and use it in GitHub Desktop.
Save CSaratakij/d91fdbacd7f518177bcd4c5c310a7ecf to your computer and use it in GitHub Desktop.
using UnityEngine;
public class Example : MonoBehavoiur
{
[SerializeField]
GameObject prefab;
bool isTrigger = false;
void OnTriggerEnter(Collider col)
{
//should compare tag first...
//then
if (isTrigger) { return; }
isTrigger = true;
//instantiate here...
Instantiate(prefab);
}
void OnTriggerExit(Collider col)
{
//should compare tag first
//then
isTrigger = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment