Quantcast
Viewing all articles
Browse latest Browse all 1488

UNITY shooting script does nothing

UNITY shooting script wont work. i asigned alll values. how can i fix it? using System.Collections; using System.Collections.Generic; using UnityEngine; public class attack : MonoBehaviour { public float monsterhealth = 30; public float monsterhealthdecreese = 1f; public float monsterdeath = 1f; public Transform monster; public Transform rangecapsule; // Use this for initialization void Start () { } // Update is called once per frame void FixedUpdate () { if (Input.GetKey("r")) { damage(); } } void damage() { if (Vector3.Distance(rangecapsule.position, monster.position) < 1) { monsterhealth = monsterhealth - monsterhealthdecreese; print("The monster is at " + monsterhealth + " health!"); if (monsterhealth < monsterdeath) { print("You killed a monster!"); Destroy(monster); } } else { print("You cannot shoot! you are to far away!"); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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