SolvedDetecting Player Motion

Posts 1–5 of 5 · Page 1 of 1
Detecting Player Motion
Is there any way to detect if the player is in motion? For Example, if the player is not in motion, give them Damaging?
if the player stopped sending move packets since the last tick (you might want to add a grace period) => motion stopped (take away buff)
if the player sends move packets constantly => in motion
if the player didn't send a move packet last tick, but he sent one just now => motion starting (apply buff)
this is very inefficient btw, i just told you the core of it, there are many optimizations that could be done (like making the whole thing not tick based, or at least stopping the loop while the player isn't in motion)
Quote Originally Posted by FlutterM4rk View Post
if the player stopped sending move packets since the last tick (you might want to add a grace period) => motion stopped (take away buff)
if the player sends move packets constantly => in motion
if the player didn't send a move packet last tick, but he sent one just now => motion starting (apply buff)
this is very inefficient btw, i just told you the core of it, there are many optimizations that could be done (like making the whole thing not tick based, or at least stopping the loop while the player isn't in motion)
There is an issue with that, the player sends a move packet every tick even if the player didn't move.
Basically just create a variable called lastLocation, set it to the position before the player started moving, and check if lastLocation = position for a certain amount of time. Then, apply the buff, else remove the buff.
Quote Originally Posted by zylixel View Post
Is there any way to detect if the player is in motion? For Example, if the player is not in motion, give them Damaging?
Where are you trying to implement this? It can easily be created as a behavior, if you're trying to make an ability then best of luck.
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?