- Home /
Make gameobject appear on collision
This is the unityscript that I am using so that my enemy will appear when I collide with something. The problem is that it does absolutely nothing! The enemy(smiledog) appears right away and nothing happens when I collide with the object. I've selected the gameobject for the script and everything.
collider.isTrigger = true;
var smiledog : GameObject;
function OnTriggerEnter ( other : Collider) {
Instantiate (smiledog);
}
Have you set the is Trigger to Checked in the Collider Component of that GameObject. ?
yes, I did. the gameobject always appears right when I start the game.
Answer by electricsauce · Feb 18, 2013 at 04:23 AM
You might need to specify which collider needs to trigger the instantiation.
OnTriggerEnter...
if(Collider.name == "Player") { Instantiate... }
or check against the tag of the collider
Your answer
Follow this Question
Related Questions
Instantiate problem 1 Answer
Instantiate A Prefab 1 Answer
How to create an instance of a class stored in another script 0 Answers
Where to attach a script? 1 Answer
How to create GameObject without adding it to scene? 1 Answer