Hello, I am looking to create minigame spawn points and I want all players to automatically look at a middle point which I set. So when players spawn in different locations they will all look at the direction to the middle point. How can I do that?
This should help you https://github.com/johnnywoof/NoHack/blob/master/NoHack/src/com/lenis0012/bukkit/npc/NPC.java Google can be your friend.
You could try something like: Code (Text): //middlePt would be the Location object of your middle location double x = middlePt.getX() - player.getLocation().getX(); double y = middlePt.getY() - player.getLocation().getY(); double z = middlePt.getZ() - player.getLocation().getZ(); Vector playerLookDirection = new Vector(x, y, z);//make a vector going from the player's location to the center point player.getLocation().setDirection(playerLookDirection.normalize());
Code (Java): World w = // get world double x = // get x double y = // get y double z = // get z double yaw = // get yaw double pitch = // get pitch Player#setLocation(new Location(w, x, y, z, (float) yaw, (float) pitch));
First, he's trying to calculate the yaw/pitch needed for the player to be looking at the location without knowing the yaw/pitch before hand. Second, that's not a method.
well now I know that setting a player's new location is not a method my bad you didn't understand carefully, expected that all values to get would be in config.
No you're the one who didn't understand. He's trying to make a list of players look at the same location, so he needs to calculate each one individually in the code.
lool yeaaaaah boy Wrong thread I thought it was the bukkit ones whom I was talking to. he's asking for set location then go with yaw and pitch. its really shameful hahaha didn't read what @OP's talking about.