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

Checking what type of enemy you hit

$
0
0
Hey so im creating a game where there is going to be alot of enemies and i use raycast for my melee weapon right now im checking the hit collider tag but that will make a big script if i should do it on every enemy so how should i do it? this is how i do it right now private void DoAttack() { Ray ray = playingCam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, myWeapon.attackRange)) { myWeapon.attackDamage = Random.Range(myWeapon.minAttackDamage, myWeapon.maxAttackDamage); if (hit.collider.tag == "StoneGolem") { StoneGolemController eHealth = hit.collider.GetComponent(); eHealth.TakeDamage(myWeapon.attackDamage); Debug.Log(myWeapon.attackDamage); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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