- Home /
 
 
               Question by 
               yowotell · Dec 22, 2015 at 08:11 AM · 
                scripting problem  
              
 
              can some 1 help with my script. im making a wood cuting script.
im making a wood cutting script and i got the basics.
i can shop te tree down the health drains the tree wil be removed and there is spawning a log
but the logs wil also be destroyed
i hope some 1 can help 
   #pragma strict
 var startingHealth : int = 40;            
 var currentHealth : int;                   
 var logs :Transform;
 var tree :GameObject;
 var oak :GameObject;
                                          
 private var isDead : boolean;                                
 
 
 function Awake ()
 {
      currentHealth = startingHealth; }
 
       public function TakeDamage (amount : int, hitPoint : Vector3)
     {
    
     if(isDead)
     
     return;
 currentHealth -= amount;
 if(currentHealth <= 0)
 {
    
     Destroy ();
 }
 }
    function Destroy ()
    {
    //Destroy (gameObject, 2f);
 
 var position : Vector3 = Vector3(Random.Range(.1, .1), 2, Random.Range(.1, .1));
 Instantiate(logs, transform.position, transform.rotation);
 }
 
              
               Comment
              
 
               
              Your script is very difficult to follow.... partly because your formatting and indentation is terrible. What object is it attached to? The player? The log? The tree? Why does the "Destroy" function not destroy anything, but rather Instantiate something? What is isDead for?
Your answer