Titel says it all. I’ve been watching Brackeys tutorials on how to make your own game, and i’ve used his PlayerStats and Weapondamage script. But for some reason when I aim down on the ground and i start punching i’m hitting myself for some reason.
I also have a second problem, where i put in the Punch animation ( also from Brackey’s tutorials ) and i use the Animator for it but for some reason, when i click multiple times without letting the animation run out, it does several amounts of damage. Is there a way to fix that?
PlayerStatsV2 Script:
And the WeaponDamage script:
Thanks already for any help. ( I’m a beginner FYI )
( Hit01 and Hit02 are the animations of the Punching and swinging of weapons )
For the raycast thing: maybe the camera isn’t fully in the collider of the player, so that it detects it when looking down? If not, you could just write an if before the sendMessage, like this:
if(hit.transform.gameObject != Camera.main.gameObject)
{
//Do the broadcast
}
I’m no good in animations, but maybe you could check if an animation is in progress, and if yes, then ignore the whole attackdamage function.
Also, just a little tip: at the start of the attackdamage function, you could use an else if, so that it’s easier to read, like this: