- Home /
collisions not working - do they have to be part of an update function?
Hi - So I've got a simple game set up in which objects are spawned at different locations for collection. I also have an enemy that is patrolling the perimeter. The enemy has a controller, and a sub-object with a collider, which was set up to allow it to cause damage to the character if it comes in contact. However, I want the enemy to ignore collisions with the spawned objects (just pass through them), but my code doesn't seem to be working. From the awake function, I call this:
 var enemyRef: GameObject; //drag the gameobject into the inspector that is the enemy
 
 function Awake()
 {
     for (var j:int = 0; j < numberOfPickups; j++)
     {
         SpawnPickup();
     }
 }
 
 function SpawnPickup(){
 
 // instantiate (create) the pickup prefab with the above position and rotation
 var spawnedPickup:GameObject = Instantiate(pickupPrefab, spawnedPickupPosition, spawnedPickupRotation);
 Physics.IgnoreCollision( spawnedPickup.collider, enemyRef.collider);  //TODO: Get enemy to ignore spawnedPickups 
 
 }
Is it not working because it needs to be continually detected? Is it because I have a game object with a collider as a child of a game object with a controller? Thanks for any help you can provide.
Answer by sneftel · Jul 19, 2011 at 07:00 PM
The character controller itself acts as a collider. Make sure you ignore collisions with that too.
I've added that, but I think my script isn't working for either.
Your answer
 
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
dragging out an object from mouse click? 1 Answer
Collsions - Objects just passing through each other 1 Answer
Adding a spawn location? 2 Answers
checking two seperate objects collision 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                