So I have a power up where if I have it on, it kills the enemy on contact with the player. Pretty popular power up, but if I were to die, and then get that power up, it doesn't work. The power up shows it is checked in the inspector, the character's texture changes signifying it is on, but once touching an enemy, the player dies as if the power up wasn't even on.
Looked at my code for like an hour and I cannot tell what is wrong with it. Here is the enemy script:
var Player : GameObject;
var spawnPoint : Transform;
var stomp : boolean;
var thePrefab: GameObject;
private var coin : GameObject;
private var player : PlayerScript;
function Start(){
player = GameObject.FindWithTag("Player").GetComponent(PlayerScript);
}
function Update () {
}
function OnTriggerEnter(other : Collider){
if(!stomp){
if(other.tag == "Player"){
if(player.Diamond == true){
coin = Instantiate(thePrefab, transform.position, Quaternion.identity);
Destroy(gameObject);
}
else if(player.Pick == true && player.Diamond == false){
player.Pick = false;
return;
}
else {
var Player : GameObject = Instantiate(Player, spawnPoint.position, Quaternion.identity);
Destroy(other.gameObject);
}
}
}
}
I'm open to all suggestions and will answer any questions that might better help you understand my situation.
↧