New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLAYER:SetPos Fails when called in sweps #2447
Comments
👍 I seemed to have the issue outside of SWEPs as well, though. I had a high failure rate setting positions while the player isn't finished loading in (but their object exists), so I'm led to believe that network lag between the client and server may have some role in this. |
I think it's due to prediction desync. It might work properly if the player/weapon is set to not be predictable. |
Not entirely prediction but player movement actually, PrimaryAttack/Think/ and the other (predicted) weapon hooks are called within the player movement code, and since the movement code is already in process and the functions are called in the middle of it, SetPos will appear to have no effect since it will be overridden right after the movement is done calculating the position to put the player in. As for @KingofBeast 's problem, also related to player movement, since the movement of a player is only calculated when the player sends packets ( usercmd inputs ), during loading screens and such the player's gmod is still loading crap and thus not really sending usercmds, making it look like the player object is frozen and can't even be pushed around sometimes. Btw this is not a "hurrr you're doing it wrong guys" post, but just a note on what's happening. |
@Jvs34 Thanks for the explanation. Is there a reason the weapon's predicted hooks are called before movement calculations? |
That's just the way it is, no particular reason other than Valve wanted the order to be like this. |
Kefta lead me to this subject as I was having the same issue in my point_teleport entity, Jvs is right but GMod doesnt provide the binding for the Teleport function which takes care of it. http://codepad.org/tVu0cBWv thats thats the correct code to call. |
@willox plz |
Well there is a way to get around it, I did following http://codepad.org/ZKkU16j6 |
PLAYER:SetPos Fails when called in sweps and GetPos returns the new pos until the next frame.
Test Code
Output
Video
https://f.stonedpengu.in/index.php/s/LqReMgERmgJ19FI
The text was updated successfully, but these errors were encountered: