Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy Health Won't go Down

$
0
0
I'm following a tutorial on youtube (https://www.youtube.com/watch?v=Q_o74dbn3ZU&list=PLZ1b66Z1KFKik2g8D4wrmYj4yein4rCk8&index=11). They are using unity 5 and I'm using unity 5.6. Our scripts are identical and attached to the same things, but I have the error "NullReferenceException: Object reference not set to an instance of an object AttackScript.Update () (at Assets/Scripts/AttackScript.js:11)". This is the script: var hitpoint : int = 10; var totarget : float; var range : float = 5; function Update () { if (Input.GetButtonDown("Attack")) { var hit : RaycastHit; if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) { totarget = hit.distance; if (totarget < range) { hit.transform.SendMessage("DeductPoints", hitpoints, SendMessageOptions.DontRequireReciever); } } } } What did I do wrong?

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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