diff --git a/res/modules/internal/stdcomp.lua b/res/modules/internal/stdcomp.lua index db78bc7a8..4278f14f6 100644 --- a/res/modules/internal/stdcomp.lua +++ b/res/modules/internal/stdcomp.lua @@ -38,6 +38,7 @@ local Rigidbody = {__index={ get_elasticity=function(self) return __rigidbody.get_elasticity(self.eid) end, set_mass=function(self, v) return __rigidbody.set_mass(self.eid, v) end, set_elasticity=function(self, v) return __rigidbody.set_elasticity(self.eid, v) end, + get_ground_vel=function(self) return __rigidbody.get_ground_vel(self.eid) end, }} local function new_Rigidbody(eid) diff --git a/src/logic/scripting/lua/libs/lib__rigidbody.cpp b/src/logic/scripting/lua/libs/lib__rigidbody.cpp index 52234f91e..a36f2b080 100644 --- a/src/logic/scripting/lua/libs/lib__rigidbody.cpp +++ b/src/logic/scripting/lua/libs/lib__rigidbody.cpp @@ -192,6 +192,14 @@ static int l_set_elasticity(lua::State* L) { return 0; } +static int l_get_ground_vel(lua::State* L) { + if (auto entity = get_entity(L, 1)) { + return lua::pushvec3(L, entity->getRigidbody().hitbox.groundVelocity); + } + return 0; +} + + const luaL_Reg rigidbodylib[] = { {"is_enabled", lua::wrap}, {"set_enabled", lua::wrap}, @@ -217,5 +225,6 @@ const luaL_Reg rigidbodylib[] = { {"set_mass", lua::wrap}, {"get_elasticity", lua::wrap}, {"set_elasticity", lua::wrap}, + {"get_ground_vel", lua::wrap}, {nullptr, nullptr} };