Question by
m9playsgames · Feb 26, 2017 at 12:55 PM ·
raycastfpsshootingraycasthitdamage
Disable Damage Raycast?
Hey guys. First time posting a question here. I'm pretty new at Unity and have been learning using YouTube and other tutorials.
At the moment, I have a raycast script running to hit enemies when shooting my handgun, and it also serves to pick up items with an Action Key (E)
However, even when I don't have the gun equip, they raycast deals damage to the enemy. Is there a way to disable it? Should I do this in the enemy script or raycast?
Please help. Thank you!
var EnemyHealth : int = 25;
function DeductPoints (DamageAmount : int) {
EnemyHealth -= DamageAmount;
}
function Update () {
if (EnemyHealth <= 0) {
Destroy(gameObject);
}
}
Comment
Answer by TheDankchicken45 · Jul 22, 2021 at 06:17 PM
dont run the damage function if you dont have a gun.