mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'step-height' entity property
This commit is contained in:
parent
99106df230
commit
0f63fd64ed
5 changed files with 7 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue