mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add BodyType, fix crouching
This commit is contained in:
parent
7e80642ec3
commit
0a14d6220a
13 changed files with 131 additions and 34 deletions
|
|
@ -85,7 +85,7 @@ entityid_t Entities::spawn(
|
|||
const auto& tsf = registry.emplace<Transform>(
|
||||
entity, position, glm::vec3(1.0f), glm::mat3(1.0f), glm::mat4(1.0f), true);
|
||||
auto& body = registry.emplace<Rigidbody>(
|
||||
entity, true, Hitbox {position, def.hitbox}, std::vector<Trigger>{});
|
||||
entity, true, Hitbox {def.bodyType, position, def.hitbox}, std::vector<Trigger>{});
|
||||
|
||||
body.triggers.resize(def.radialTriggers.size() + def.boxTriggers.size());
|
||||
for (auto& [i, box] : def.boxTriggers) {
|
||||
|
|
@ -307,8 +307,6 @@ void Entities::updatePhysics(float delta) {
|
|||
&hitbox,
|
||||
delta,
|
||||
substeps,
|
||||
false,
|
||||
true,
|
||||
eid.uid
|
||||
);
|
||||
hitbox.linearDamping = hitbox.grounded * 24;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "../typedefs.hpp"
|
||||
#include "../maths/aabb.hpp"
|
||||
#include "../physics/Hitbox.hpp"
|
||||
|
||||
namespace rigging {
|
||||
class RigConfig;
|
||||
|
|
@ -18,6 +19,7 @@ struct EntityDef {
|
|||
|
||||
std::vector<std::string> components;
|
||||
|
||||
BodyType bodyType = BodyType::DYNAMIC;
|
||||
glm::vec3 hitbox {0.5f};
|
||||
std::vector<std::pair<size_t, AABB>> boxTriggers {};
|
||||
std::vector<std::pair<size_t, float>> radialTriggers {};
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ void Player::updateInput(PlayerInput& input, float delta) {
|
|||
speed *= CHEAT_SPEED_MUL;
|
||||
}
|
||||
|
||||
hitbox->crouching = crouch;
|
||||
if (crouch) {
|
||||
speed *= CROUCH_SPEED_MUL;
|
||||
} else if (input.sprint) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue