- Home /
Spawning a new sphere when 2 other spheres collide.
This is probably pretty simple. Id like to spawn a new sphere right between 2 other spheres when they collide. The new spawned sphere would be small like 20% of the size of one of the other 2, but id probably want to set the size of the new spawned sphere. I tried figuring this out but am stuck.
Comment
Answer by fafase · Aug 07, 2012 at 10:36 AM
function OnCollisionEnter(other:Collision){
if(other.gameObject.tag=="OtherSphere"){
var sphere : GameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = other.contacts[0].point;
sphere.transform.localScale = Vector3(0.2,0.2,0.2);
}
}
Attach this to one of the sphere only or you would create two sphere. This will create a sphere and position it where they collide and scale it down to 0.2.
Your answer
Follow this Question
Related Questions
spawning on collision 1 Answer
Respawn random objects 1 Answer
Spawning if there is space 1 Answer
Spawning object at random, collision-free position 4 Answers
Spawner continuing after boss dies 1 Answer