add entity.rigidbody.get_ground_vel

This commit is contained in:
MihailRis 2026-03-22 22:54:50 +03:00
parent 3ab5095583
commit 1fb0eb762d
2 changed files with 10 additions and 0 deletions

View file

@ -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)

View file

@ -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<l_is_enabled>},
{"set_enabled", lua::wrap<l_set_enabled>},
@ -217,5 +225,6 @@ const luaL_Reg rigidbodylib[] = {
{"set_mass", lua::wrap<l_set_mass>},
{"get_elasticity", lua::wrap<l_get_elasticity>},
{"set_elasticity", lua::wrap<l_set_elasticity>},
{"get_ground_vel", lua::wrap<l_get_ground_vel>},
{nullptr, nullptr}
};