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
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);
}
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.