- Home /
switch object when collided with?
i want to switch object 1 to object 2 when collided with my object. how can i do that? object 1 being a gameObject that has 1 cube and object 2 being a gameObject that has 6 spheres in for an example. first 20 CORRECT AND HELPFUL ANSWER ILL PAY THEM $276-$2,000
I personally wouldn't post a helpful comment for a penny less than $277. ;)
Answer by Taran0 · Jul 05, 2011 at 03:42 PM
make a gameobject variable and assign your second object into it and add the following script to your first object. it instantiates the second object when the first object collides with something.
var object2 : GameObject;
function OnCollisionEnter (col : Collision) {
Instantiate(object2, transform.position, transform.rotation);
Destroy(gameObject);
}
Answer by Chris D · Jul 05, 2011 at 03:40 PM
Consider the basic steps that are required here:
Detect your collision
destroy object1
instantiate object2
Short of writing your script for you (which I try to avoid), that's your answer. Please remember to search through old answers before posting; this kind of thing get asked often and there are plenty of solutions there to look through.
Your answer
Follow this Question
Related Questions
switching turns between two game objects. 1 Answer
collision with objects, physics 1 Answer
Dive collide 2 Answers
Trouble with light switch 3 Answers
How to make a GameObject that collides but the player can go through it? 2 Answers