[ASK] Changing entity facing direction / head direction.

Discussion in 'Spigot Plugin Development' started by Gober, Jun 29, 2018.

  1. I've been trying to make an entity to face the direction the player is facing. However, it doesn't work well.
    Im not sure but maybe, because of these factors:
    • The entity is being ridden by the player
    • Bad Code

    Is it possible to make the entity facing the direction the player is facing?
    I tried:
    Code (Java):
                Location ploc = p.getLocation();
                Float pyaw = loc.getYaw();
                Float ppitch = loc.getPitch();
    // Above this are players
                Location enloc = entity.getLocation();
                enloc.setYaw(pyaw);
                entity.teleport(enloc);
    The above code doesn't work (im using 1.12.2)
    Any solution? Couldn't get this to work even after days.
     
  2. Try Player#getEyeLocation()
     
    • Like Like x 1
  3. Doesn't work for me.

    Code:
    Code (Java):
                Location peye = p.getEyeLocation();
                Float pyaw = peye.getYaw();
                Float ppitch = peye.getPitch();
                Location enloc = en.getLocation();
                enloc.setPitch(ppitch);
                enloc.setYaw(pyaw);
                en.teleport(enloc);
     
  4. Still doesn't work :(
     
  5. You need to give more details whats not working and what you tried
     
  6. @Gober I had the same issue for my Merry-Go-Round gadget in ProCosmetics. My solution was to add an armorstand between the entity you ride and you. After that, I could set pitch & yaw for the horse. :)
     
    • Like Like x 1
    • Useful Useful x 1
  7. How's that possible?