Enemies/GameObject disappearing after initial animation
Hi Guys,
Probably just a silly one this, but I've added an Alien enemy with appropriate animations which I can attack and kill via RayCastHit. All this works fine.
My problem is, after the initial Idle_Walkaround animation has run, the Alien/GameObject just disappears/Destroys from Hierarchy.
I've written a couple of simple scripts to facilitate the damage and player attack using raycasthit. Is there somthing I'm doing wrong that's causing the gameObjects to Destroy?
Here's the code.
--- enemyScript ----
var health = 100; var deathClip : AnimationClip;
function Update(){
 if(health <= 0){
     GameObject.Find("enemy").GetComponent.<Animation>().Play("die1");
 }
}
function applyDamage(){ health -= 10; print("Enemy Health: " + health + "%"); }
--------END enemyScript---------
-------playerScript----------
function Update(){
 var forwardPosition = transform.TransformDirection(Vector3(0,0,10));
 var playerRayHit : RaycastHit;
 if(Physics.Raycast(transform.position, forwardPosition, playerRayHit)){
 
     //print("ray is active");
     //print("object name: " + playerRayHit.transform.name);
     if(Input.GetMouseButtonDown(0) && playerRayHit.transform.name == "enemy"){
         playerRayHit.transform.SendMessage("applyDamage");
         }
 }
}
------END playerScript---------
I'm a novice scripter, so please excuse any obvious errors, Thanks.
Your answer
 
 
             Follow this Question
Related Questions
GameObject.Destroy(gameObject); Not Working? 0 Answers
Gameobject is null for no reason 1 Answer
Static Gameobjects Destroy on Reload 0 Answers
The bullet never destroyed!!! 2 Answers
Object Pool and components 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                