GetPitch, GetRoll, SetPitch and SetRoll
#1
i am trying to recreate the bukkits Spectate plugin but I found a bug in the SetPitch and SetRoll function. Becouse i use that to set the position the player is looking at but it doesn't work all the time. If i try to look at something only like 10 seconds later the other client looks at the same spot. But when i try print(Player:GetRoll()) and print(User:GetRoll()) they are the same. Also the cWorld:FindAndDoWithPlayer() function is putting out an message everytime i use it and since i use it in a OnTick function the console get spammed Wink
Reply
Thanks given by:
#2
This is just a shot in the dark since I'm still getting familiar with how plugins are integrated with MC, but have you tried adding the SetHeadYaw/GetHeadYaw functions when you set the rotation? We separated the entity rotation from the head yaw a couple of revs back, so this could be the cause of your issue. Also, does it last exactly 10 seconds? or is it around 20 seconds? I asked because the MC server sends every 20 seconds a teleport packet that contains the pitch and rotation (but not head yaw) to keep the client synchronized, so this could also be causing the issue.
Reply
Thanks given by:
#3
I have a feeling that setting the rotation / pitch / yaw using those functions only updates the entities server-side, it doesn't propagate the rotations to the player (so it won't "force you to look left", it will just make you look as if you were looking left, for other players). Just a guess, though.
Reply
Thanks given by:
#4
well it seems to be fixed when i move like 20 blocks. then the player is forced to look at that spot. but should i use the SetHeadYaw/GetHeadYaw function with the SetPitch etc functions?
Reply
Thanks given by:
#5
Yeah, you should give the same value that you give to SetRotation to SetHeadYaw since they should match when you want to look at a position.

What xoft says could also be a reason because during the player entity tick, the current player is excluded from getting the positions/rotation/speed packets.
Reply
Thanks given by:
#6
I find it strange that SetRotation etc. works at all for changing a clients orientation...
The only function that is capable of updating a clients pose is cClientHandle::SendPlayerMoveLook(). This function is only called for cPlayer::TeleportTo() and when the server thinks a client is "out of sync" after receiving the client's position (probably what is happening)...

I suggest you try calling Player:GetClientHandle:SendPlayerMoveLook() manually after setting the player's pose. This will most likely move the client to where you want him to go.

I am a little concerned though (and it's the same with teleporting right now) that while client position is on its way to the client, the server might receive an old position after which the server position is set to the old client position. Then the client receives the new position and sends the new position back to the server. On the server side this might cause the client to jump back and forth a couple of times. This is all speculation though, I'm not sure about this.

EDIT: Nevermind.. SendPlayerMoveLook is not exposed to Lua
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)