Calculate Hit location ?

Discussion in 'Plugin Development' started by Geoneo97, Sep 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Geoneo97

    Hello
    I am trying To Make a Plugin

    OK, i try To get the location where the player gets hittet!

    Wiht a projectile its easy
    Get projectile get location

    But how works this in an sword fight?
    Example: you hit a player with a sword on his head
    Now it tellme a number

    Player1 Hit Player2

    Location location1 = ???
    Locatiob location2 = Player2.getLocation();

    Double number = location1.getY() - location2.getY();

    Player1.sendMessage("High: " + number);

    How can i geht location1
    (Location where Player gets hittet by Sword, i habe done this with projectiles it works location1 = projectile.getLocation(); than i get the location where Player2 gets hittet by the projectile ,Head ,Legs and More but how can i geht
    The hittet location Form example a sword?)

    I think i must use yaw pitch or looking direction
    But how
     
  2. Offline

    coasterman10

    You can get the attacking player's eye location direction vector and find the intersection with the attacked player's bounding box. This is not quite the easiest task to get right and will certainly involve some intensive geometry. This process is known as raycasting and it is very well-known within the gaming programming community, some quick Googling will get you a number of good results.
     
  3. Offline

    Geoneo97

    coasterman10
    Ok but what can i do now ? i found nothin about Bukkit raycasting
     
Thread Status:
Not open for further replies.

Share This Page