It doesn't appear that teleporting the player with a set pitch is working. Yaw and Position seem fine, but pitch is always set to 0.
The pitch is $sender->getName()->getLocation()->pitch Then, on the teleport function use teleport(x,y,z,yaw,pitch); Worked fine for me
Please confirm before you post. $sender->getName(), assuming your $sender is a CommandSender, returns a string. You cannot call methods upon it.
OOps I also know why i posted this crap ..i copied from my old plugin base -.-" This is the correct code: PHP: $sender->getServer()->getPlayer($sender->getName())->getLocation()->pitch
Ok, why are we even trying to "get" the player's pitch? I am just trying to set a new pitch when i teleport (like for an automated tour of the level, as a camera) Here's my code. $this->plugin->getLogger()->info("teleporting with pitch of: " .$loc->getPitch()); $this->cam->teleportImmediate($pos, $loc->getYaw(), $loc->getPitch()); I have also tried setPositionAndRotation or just the "teleport" and not teleport immediate. I've tried using an android device and an iPad... And I've tried looking at the pocketmine source and it seems correct. But whatever happens, the client does not appear to accept the change in pitch. In fact... whatever pitch it has is always canceled and set to zero. I'm almost sure this is not a pocketmine issue but a feature of the client, but I wanted to confirm with you fine folks.
Ok, here's the actual pocketmine code public function teleport(Vector3 $pos, $yaw = null, $pitch = null) Now... I'm using build #1258.... what version are you using? Because if I try using $player->teleport(x,y,z,yaw,pitch); I get an error. The first parameter must be a Vector3
Yeah, thanks for finally posting a piece of code that will not crash my game, but as I've said, this is not working as intended.
Have you tried pitch=7 yaw=10? I dont know how high the pitch can be I made a function so that if i do /loc, i get the Location. I think it was $sender->getLocation->__toString();
http://en.wikipedia.org/wiki/Yaw,_pitch_and_roll Note: PocketMine saves the things in degrees, but keep in mind that PHP trigonometric functions use radians.
Ok... so I tried this again assuming it would only accept teleport pitchs in radians between -1.57 and 1.57 Code: $nextfloat = rand() / getrandmax();; $nextPIAlter = $nextfloat * M_PI; $randPitch = (-M_PI * .5) + $nextPIAlter; $this->cam->teleport($pos, $loc->getYaw(), $randPitch); This of course did nothing.
Also i want to mention, you should not use deg2rad() or rad2deg() in loops, they're kind of slow. Use $rad = ($deg * M_PI / 180) instead. But if you only call the function once (i guess you'll only teleport once ) you could use them. Also, i would use mt_rand or rand instead of lcg_value, but lcg_value is faster. (By the way, you can do rand(0,getrandmax()))
WOW, REALLY FUNNY. The point of this thread is that the teleporting of a player with pitch is not working as intended. I assume that you two do not have any solutions to the problem... thank you though. Also, great job clicking "like "on each other's posts. I can see that you guys are really pillars of the community, with so many likes to your names. Please... either confirm that there is a problem, or show me a solution. I'm not interested in playing forum games.