add 'step-height' entity property

This commit is contained in:
MihailRis 2026-02-13 02:48:40 +03:00
parent 99106df230
commit 0f63fd64ed
5 changed files with 7 additions and 1 deletions

View file

@ -88,4 +88,5 @@ template<> void ContentUnitLoader<EntityDef>::loadUnit(
root.at("skeleton-name").get(def.skeletonName);
root.at("blocking").get(def.blocking);
root.at("step-height").get(def.stepHeight);
}

View file

@ -42,6 +42,9 @@ struct EntityDef {
/// @brief Does entity prevent blocks setup
bool blocking = true;
/// @brief Max obstacle height that does not require jumping
float stepHeight = 0.5f;
/// @brief save-** flags
struct {
bool enabled = true;

View file

@ -80,4 +80,5 @@ void Rigidbody::initialize(
create_sensor_callback<scripting::on_sensor_enter>(entities),
create_sensor_callback<scripting::on_sensor_exit>(entities)};
}
hitbox.stepHeight = def.stepHeight;
}

View file

@ -59,6 +59,7 @@ struct Hitbox {
bool grounded = false;
float gravityScale = 1.0f;
bool crouching = false;
float stepHeight = 0.5f;
Hitbox(BodyType type, glm::vec3 position, glm::vec3 halfsize);

View file

@ -42,7 +42,7 @@ void PhysicsSolver::step(
vel += gravity * dt * gravityScale;
if (hitbox.type == BodyType::DYNAMIC) {
colisionCalc(chunks, hitbox, vel, pos, half,
(prevGrounded && gravityScale > 0.0f) ? 0.5f : 0.0f);
(prevGrounded && gravityScale > 0.0f) ? hitbox.stepHeight : 0.0f);
}
pos += vel * dt + gravity * gravityScale * dt * dt * 0.5f;