im making a sort of FPS in the middle ages(bows, swords, etc...) im working on combat. ive got it so where the arrow hits the zombie and he groans. i did this by measuring the entity distance between the arrow, and the zombie. i measured it saying: there are 5 units between the head and the center of the zombie, so the arrow needs to be within 5 units of the center of the zombie. sounded good at first, but that means 5 units from the center in any direction. 5 units to the side is a perfect miss, and he still dies...
anyone know a better way to do this?
Why ONLY check 5 units?
Why not do something like:
[pseudocode]
IF (X amount is less than 1.5 from center) AND (Y amount is less than 5 units from center) THEN (arrow struck zombie)
[/pseudocode]
Or you could just set up Collisions between your arrows and zombies and let Blitz do the work for you.
But ... his code works and is simple. I don't see any inherent problem with what he's doing. If it works and does what you want it to, rock on.
If your ground is flat then you can measure the entitydistance of them, and also get the difference in Y height. Do something like:
If abs(EntityY(arrow,true)-EntityY(zombie,true))<5 then
Make sure the entity distance between the two is close though.