fix body:set_gravity_scale & fix docs
This commit is contained in:
parent
e61e8a6147
commit
8b38d57966
@ -86,9 +86,9 @@ body:get_size() -> vec3
|
|||||||
body:set_size(size: vec3)
|
body:set_size(size: vec3)
|
||||||
|
|
||||||
-- Returns the gravity multiplier
|
-- Returns the gravity multiplier
|
||||||
body:get_gravity_scale() -> vec3
|
body:get_gravity_scale() -> number
|
||||||
-- Sets the gravity multiplier
|
-- Sets the gravity multiplier
|
||||||
body:set_gravity_scale(scale: vec3)
|
body:set_gravity_scale(scale: number)
|
||||||
|
|
||||||
-- Returns the linear velocity attenuation multiplier (used to simulate air resistance and friction)
|
-- Returns the linear velocity attenuation multiplier (used to simulate air resistance and friction)
|
||||||
body:get_linear_damping() -> number
|
body:get_linear_damping() -> number
|
||||||
|
|||||||
@ -86,9 +86,9 @@ body:get_size() -> vec3
|
|||||||
body:set_size(size: vec3)
|
body:set_size(size: vec3)
|
||||||
|
|
||||||
-- Возвращает множитель гравитации
|
-- Возвращает множитель гравитации
|
||||||
body:get_gravity_scale() -> vec3
|
body:get_gravity_scale() -> number
|
||||||
-- Устанавливает множитель гравитации
|
-- Устанавливает множитель гравитации
|
||||||
body:set_gravity_scale(scale: vec3)
|
body:set_gravity_scale(scale: number)
|
||||||
|
|
||||||
-- Возвращает множитель затухания линейной скорости (используется для имитации сопротивления воздуха и трения)
|
-- Возвращает множитель затухания линейной скорости (используется для имитации сопротивления воздуха и трения)
|
||||||
body:get_linear_damping() -> number
|
body:get_linear_damping() -> number
|
||||||
|
|||||||
@ -159,7 +159,7 @@ local prev_angle = (vec2.angle({dir[3], dir[1]})) % 360
|
|||||||
function on_physics_update(delta)
|
function on_physics_update(delta)
|
||||||
local grounded = body:is_grounded()
|
local grounded = body:is_grounded()
|
||||||
body:set_vdamping(flight)
|
body:set_vdamping(flight)
|
||||||
body:set_gravity_scale({0, flight and 0.0 or props.gravity_scale, 0})
|
body:set_gravity_scale(flight and 0.0 or props.gravity_scale)
|
||||||
body:set_linear_damping(
|
body:set_linear_damping(
|
||||||
(flight or not grounded) and props.air_damping or props.ground_damping
|
(flight or not grounded) and props.air_damping or props.ground_damping
|
||||||
)
|
)
|
||||||
|
|||||||
@ -54,7 +54,12 @@ static int l_get_gravity_scale(lua::State* L) {
|
|||||||
|
|
||||||
static int l_set_gravity_scale(lua::State* L) {
|
static int l_set_gravity_scale(lua::State* L) {
|
||||||
if (auto entity = get_entity(L, 1)) {
|
if (auto entity = get_entity(L, 1)) {
|
||||||
entity->getRigidbody().hitbox.gravityScale = lua::tovec3(L, 2).y;
|
auto& hitbox = entity->getRigidbody().hitbox;
|
||||||
|
if (lua::istable(L, 2)) {
|
||||||
|
hitbox.gravityScale = lua::tovec3(L, 2).y;
|
||||||
|
} else {
|
||||||
|
hitbox.gravityScale = lua::tonumber(L, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user