From 91230ecbeb3c36802d7aff48660f525f65d15feb Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 10 Jul 2024 02:34:53 +0300 Subject: [PATCH] update 'hitbox' property semantics --- res/content/base/entities/drop.json | 2 +- res/content/base/entities/falling_block.json | 2 +- res/content/base/entities/player.json | 2 +- src/logic/PlayerController.cpp | 3 ++- src/objects/Entities.cpp | 2 +- src/objects/EntityDef.hpp | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/res/content/base/entities/drop.json b/res/content/base/entities/drop.json index 47050d78..b40e11f0 100644 --- a/res/content/base/entities/drop.json +++ b/res/content/base/entities/drop.json @@ -2,7 +2,7 @@ "components": [ "drop" ], - "hitbox": [0.2, 0.125, 0.2], + "hitbox": [0.4, 0.25, 0.4], "sensors": [ ["aabb", -0.2, -0.2, -0.2, 0.2, 0.2, 0.2], ["radius", 1.6] diff --git a/res/content/base/entities/falling_block.json b/res/content/base/entities/falling_block.json index 9cabe1d7..ecf269c5 100644 --- a/res/content/base/entities/falling_block.json +++ b/res/content/base/entities/falling_block.json @@ -3,5 +3,5 @@ "falling_block" ], "rig-name": "base:block", - "hitbox": [0.4, 0.4, 0.4] + "hitbox": [0.8, 0.8, 0.8] } diff --git a/res/content/base/entities/player.json b/res/content/base/entities/player.json index cfbc80db..36be7bab 100644 --- a/res/content/base/entities/player.json +++ b/res/content/base/entities/player.json @@ -1,3 +1,3 @@ { - "hitbox": [0.3, 0.9, 0.3] + "hitbox": [0.6, 1.8, 0.6] } diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 006510ec..4cbb77a2 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -143,9 +143,10 @@ void CameraControl::switchCamera() { } void CameraControl::update(const PlayerInput& input, float delta, Chunks* chunks) { - offset = glm::vec3(0.0f, 0.7f, 0.0f); + offset = glm::vec3(0.0f, 0.0f, 0.0f); if (auto hitbox = player->getHitbox()) { + offset.y += hitbox->halfsize.y * (0.7f/0.9f); if (settings.shaking.get() && !input.cheat) { offset += updateCameraShaking(*hitbox, delta); } diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index b8726efc..18e266cd 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -85,7 +85,7 @@ entityid_t Entities::spawn( const auto& tsf = registry.emplace( entity, position, glm::vec3(1.0f), glm::mat3(1.0f), glm::mat4(1.0f), true); auto& body = registry.emplace( - entity, true, Hitbox {def.bodyType, position, def.hitbox}, std::vector{}); + entity, true, Hitbox {def.bodyType, position, def.hitbox*0.5f}, std::vector{}); body.sensors.resize(def.radialSensors.size() + def.boxSensors.size()); for (auto& [i, box] : def.boxSensors) { diff --git a/src/objects/EntityDef.hpp b/src/objects/EntityDef.hpp index df9e5d18..253e4ec1 100644 --- a/src/objects/EntityDef.hpp +++ b/src/objects/EntityDef.hpp @@ -20,7 +20,7 @@ struct EntityDef { std::vector components; BodyType bodyType = BodyType::DYNAMIC; - glm::vec3 hitbox {0.5f}; + glm::vec3 hitbox {0.25f}; std::vector> boxSensors {}; std::vector> radialSensors {}; std::string rigName = name;