Quantcast
Channel: Questions in topic: "tree"
Viewing all articles
Browse latest Browse all 513

Taking down trees in game

$
0
0
I wanted to make this lumberjack game where you take down trees with your axe and it will then replace the trees with lumber (I know, that game would suck but it's for educational purposes). So I began to write the script and all that but it only replace the tree with the lumber in the begining and the health(health of the tree) does not work. It would be nice if someone helped (sorry for my english). :) The script: var myHealth : int = 60; var Damage : int = 20; var myTrunck : GameObject; var myTree : GameObject; function OnCollisionEnter (){ myHealth -= Damage; } function Update () { if(myHealth > 0) { var clone = Instantiate(myTrunck, transform.position, transform.rotation); GameObject.Destroy(myTree); } }

Viewing all articles
Browse latest Browse all 513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>