There is a script on the prefab polly called Destroy that destroys it when it collides with the bullet. the problem is it wont get destroyed and this script is the problem, the Destroy script works fine.
I polly to be destroyed then another one spawns a few seconds later.
Thanks
var polly : GameObject;
function Start () {
}
function Update () {
AttachPolly();
}
function AttachPolly(){
if(transform.childCount <= 0){
var ins : GameObject = Instantiate(polly, transform.position, transform.rotation);
ins.transform.parent = transform;
yield WaitForSeconds(2);
}
}
Add
function OnTriggerEnter ( collision : Collider )
{
if ( collision.tag == "bullet" ) {
GameObject.Destroy ( gameObject ) ;
}
}
Be sure that your trigger is either active on the collider, or change
OnTriggerEnter ( collision : Collider )
if ( collision.tag == "bullet" )
/* to * /
OnCollisionEnter ( collision : Collision )
if ( collision.collider.tag == "bullet" )
//Ensure that you have a rigidbody and collider not set to trigger if you want to use OnCollisionEnter ( ) instead...
If you are not sure about your collision being setup right, check out a Tutorial from YouTube. Otherwise, you should be good to go .
YouTube tutorials:
Basic Collisions
I am unsure if you are using a ragdoll or not when you say “polly”, so, here is a Ragdoll Physics tutorial.
I hope this helps you resolve your issue.