body part hit

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

bethamob

Member
Feb 17, 2026
1
0
1
I've got an idea for a feature that shows which body part a player hit (mostly for flavor, though maybe with damage modifiers for certain spots). Does anyone know how I could pull this off?
 
given normalized (length of 1 block) Vector A (vector from attacker to victim), and normalized (length of 1 block) Vector B (attacker's look vector (where attacker is looking)):
you can check the dot product. for starters, try broadcasting the dot product and testing different values. pay close attention to how big or small the number is when looking at a player's arms, versus their body or head.

if anyone has a better solution please correct me.

edit: feel free to ask for code examples if you don't understand what I mean
 
of course this only applies to melee hits but yeah I can't think of any other solutions for things like projectiles, explosions and a bunch of other sources like lava, lightning, cacti and whatnot
 
of course this only applies to melee hits but yeah I can't think of any other solutions for things like projectiles, explosions and a bunch of other sources like lava, lightning, cacti and whatnot
sorry for the late reply. all of this have a damage source location (the location of the cacti, projectile, lava, etc when it damages the player). you can get a vector from the source to the player. you can also create a temporary bounding box (hitbox) using SkBee and the player's current location to get an idea of where their head and limb hitboxes would be. then, the damage vector intersects with one of your hitboxes. whichever one it intersects with first, is the body part it hit.

hope this makes sense, and again, sorry for the late reply. I can draw image(s) if needed.