Okay, so I have a level where you go around (i’m using the FPC) and collect all of the pickups (by running over them) to be able to finish the level. I have 2 scripts, LevelEndable, and PickupDestroyer, that are both on my player, shown here:
PickupDestroyer
#pragma strict
var pickups : int = 3;
static var ready : boolean = false;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (hit.gameObject.name == "Pickup")
{
pickups -= 1;
Destroy (hit.gameObject);
}
if (pickups == 0)
{
ready = true;
}
}
LevelEndable
#pragma strict
var fpc : GameObject;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
if (fpc.GetComponent(PickupDestroyer).ready == true)
{
if(hit.gameObject.name == "Next Level")
{
var lvl = (Application.loadedLevel);
Application.LoadLevel (lvl + 1);
}
}
}
So my problem is that when I collide with one of the pickups, it stays where it is and doesn’t get destroyed. I believe that the collision is just not being detected. Any ideas?
(I’m on Unity 4.5)