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

Script Wont Take away health from my player when hit by enemy bullet.

$
0
0
Hi all Im having a problem where my script wont take away health by my player if it is hit by the enemy bullet, the script has been placed on my character and when hit with anything with the Tag "enemyBullet" it should take health away from my character. Thanks for any help you can offer. I am a complete noob at this so if you are going to offer advice please try explain it as simply as possible. Thanks! pragma strict var health : int = 100; var damage : int = 20; var whiteStencilGui : GUISkin; function Start () { } function Update () { } function OnCollisionEnter (collision : Collision) { if(collision.collider.tag == "enemyBullet") { health = health - damage; } } function OnGUI() { GUI.skin = whiteStencilGui; GUI.Box (Rect (Screen.width-100, 10, 100, 50), "health:" +health); } ![alt text][1] [1]: /storage/temp/33573-lastchance.jpg

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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