Character attacks AI with a Sword with a Collider box
AI has 2 spheres: ViewSphere (if player is in range of the sphere AI follows him) and AttackRangeSphere (if player is in range of sphere AI attack him);
AI has a time he must wait before attack again;
But I’ve a problem…when AI is near and Character isn’t attacking, sword is just colliding with AI…I’ve added an “IF(IsAttacking)” (if character is Attacking it inflicts damage to AI, else it return), but sometimes he done animation of attack but AI doesn’t take damage…How can I resolve? Please, I’m desperate…
If you do know how to make animation notifies and make an animation blueprint, I would add notifies when he starts his swing and when hes finished his swing to enable / disable collision on the weapon. Then you don’t need to have a bool for when hes attacking because it will only detect collision during the swing.
Is the collider actually attached to the sword, Is the collider big enough, Is the enemies collider big enough. You tun off under rendering for the collider to hide it in game, might help debug.
The video was hard to tell, so it looks like you only have the meshes collider instead of having an attached capsule collider. This is fine, just use OnComponentBeginOverlap in place of OnComponentHit on line 8 in your .cpp and let me know how that turns out.
Ok well if that does happen to be the case, you can set a tag on the collider you want to use to register taking hits with and then instead of using the OtherActor from the hit results you can use the OtherComp and check to see if it has the tag. So set a tag like, Enemy or something.
Now I’ve done it…I added a UBoxComponent attached to Sword…and done overlap method on him…but problem remains…I’ve seen the problem…if at start of attack sword is just in capsule component of AI attack doesn’t inflict damage
hmm well you could also try making a collider that just sittings in front of the player and when the weapon swings just do a Get All Overlapping Components.