Created
May 8, 2020 11:17
-
-
Save CSaratakij/d91fdbacd7f518177bcd4c5c310a7ecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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