diff --git a/src/content/loading/EntityLoader.cpp b/src/content/loading/EntityLoader.cpp index 29a72cb73..12e5313a7 100644 --- a/src/content/loading/EntityLoader.cpp +++ b/src/content/loading/EntityLoader.cpp @@ -88,4 +88,5 @@ template<> void ContentUnitLoader::loadUnit( root.at("skeleton-name").get(def.skeletonName); root.at("blocking").get(def.blocking); + root.at("step-height").get(def.stepHeight); } diff --git a/src/objects/EntityDef.hpp b/src/objects/EntityDef.hpp index 4d10a2d02..3752f3063 100644 --- a/src/objects/EntityDef.hpp +++ b/src/objects/EntityDef.hpp @@ -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; diff --git a/src/objects/Rigidbody.cpp b/src/objects/Rigidbody.cpp index 9b1f78d27..9e2edba4a 100644 --- a/src/objects/Rigidbody.cpp +++ b/src/objects/Rigidbody.cpp @@ -80,4 +80,5 @@ void Rigidbody::initialize( create_sensor_callback(entities), create_sensor_callback(entities)}; } + hitbox.stepHeight = def.stepHeight; } diff --git a/src/physics/Hitbox.hpp b/src/physics/Hitbox.hpp index 2b25bd6fe..909a48451 100644 --- a/src/physics/Hitbox.hpp +++ b/src/physics/Hitbox.hpp @@ -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); diff --git a/src/physics/PhysicsSolver.cpp b/src/physics/PhysicsSolver.cpp index 9244112e2..948a3d40d 100644 --- a/src/physics/PhysicsSolver.cpp +++ b/src/physics/PhysicsSolver.cpp @@ -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;