Getting if a Player got hit in the Back?

Discussion in 'Plugin Development' started by chasechocolate, Jan 6, 2013.

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

    chasechocolate

    How would I check if a player hit another player in the back? I think it might have to be done with comparing yaws, but can someone show me how I can do that?
     
  2. Offline

    avatarDr

    Comparing yaw with angle between entities.
     
  3. Offline

    fireblast709

    Math.abs(player1.getLocation().getDirection().angle(player2.getLocation().getDirection())) < SPECIFIED_ANGLE
    declare the specified angle yourself, it is the offset for the angles. If the part before < = 0, then the players are looking towards the same way.

    I also recommend a location comparison to see if the player is standing directly beside then (might not be neccesary)
     
  4. Offline

    chasechocolate

    fireblast709 shouldn't I make it check if it is >=o && <= 15 because they they wouldn't have to be looking in the exact direction?
     
  5. Offline

    jorisk322

    You don't need the bigger than 0 thing, because you already have the absolute value.
    <15 should work, but I recommend a slightly bigger angle. Maybe about 45 degrees.
     
  6. Offline

    chasechocolate

    Ok thanks!
     
Thread Status:
Not open for further replies.

Share This Page