Wouldn't it be great if a new flag was added to the player overrides that would allow mods to switch player control on/off, and when switched off mods could use the set_velocity() and set_acceleration() functions with the player model ?
player:set_physics_override({control=false}) -- turn off player control/movement
player:set_acceleration({x=0,y=20,z=0})
player:set_physics_override({control=true}) -- turn on player control
This would be a great addition to not only add player-knockback into the game, but many other features that modders could add into your worlds :) Let's discuss this below or here in forum:-
- Players would be able to build TNT cannons and launch themselves (or other players) across the map :)
- Removing player control for jailed players... naughty naughty!
Knockback and similar physical effects should be managed client side, since the client is already responsible for velocity, acceleration, and collision detection of the player object.
which sends the change to the client, and upon reception, the client adds the given vector to the player's current internal velocity. No need to override controls or to apply acceleration; just let normal friction and controls do their job, like what happens when e.g. on ice.
then grant yourself the noclip privilege and point west. Every time you toggle noclip, your speed gets added 10 m/s to simulate a knockback. Try it without controls or while moving forward or backward.