mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Implement adding velocity to player from Lua
The intended usecase is knockback, but there's potential for more.
This commit is contained in:
@@ -188,6 +188,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||
// Copy parent position if local player is attached
|
||||
if (isAttached) {
|
||||
setPosition(overridePosition);
|
||||
added_velocity = v3f(); // ignored
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,9 +202,13 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||
if (noclip && free_move) {
|
||||
position += m_speed * dtime;
|
||||
setPosition(position);
|
||||
added_velocity = v3f(); // ignored
|
||||
return;
|
||||
}
|
||||
|
||||
m_speed += added_velocity;
|
||||
added_velocity = v3f();
|
||||
|
||||
/*
|
||||
Collision detection
|
||||
*/
|
||||
@@ -782,6 +787,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||
if (isAttached) {
|
||||
setPosition(overridePosition);
|
||||
m_sneak_node_exists = false;
|
||||
added_velocity = v3f();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -795,9 +801,13 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||
position += m_speed * dtime;
|
||||
setPosition(position);
|
||||
m_sneak_node_exists = false;
|
||||
added_velocity = v3f();
|
||||
return;
|
||||
}
|
||||
|
||||
m_speed += added_velocity;
|
||||
added_velocity = v3f();
|
||||
|
||||
/*
|
||||
Collision detection
|
||||
*/
|
||||
|
Reference in New Issue
Block a user