Question by
Khogame · Sep 19, 2015 at 05:16 PM ·
scripting problemscripting beginner
Chopping tree script done. But all the tree with script attach are all fall.
Hello I spent all day for answer but no luck. The issue is when a player chop a tree with axe from this script
if (hit.collider.tag == "Tree") {
//to check if there are a tree or not;
hit.transform.SendMessage("treeDmg",dmg);
//call treeDmg function;
to this script
void treeDmg(int dmg){
treeHealth -= dmg;
}
void Update () {
if (treeHealth <= 0) {
treeRigidbody.isKinematic = false;
treeRigidbody.AddForce (transform.forward * speed);
//DestroyTree ();
}
}
void DestroyTree()
{
Debug.Log("Tree Destroy");
}
The problem is after treeHealth deplete to 0 or less every tree with the second script attach are all fall. Thank you for every advice.I'm new to scripting.Sorry for bad english.
Comment
Your answer

Follow this Question
Related Questions
Change Audio Mixer through script for every scene 0 Answers
Why Does this not work? please someone help me i am new to coding. 1 Answer
help to edit this script, zoom text ui 0 Answers
How to restrict rotation? 0 Answers
Toggling Script from another GameObject on/off Correctly using Unity Input System 1 Answer