mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
update RigConfig
This commit is contained in:
parent
1b41a75cf4
commit
beac332c96
15 changed files with 230 additions and 62 deletions
|
|
@ -36,7 +36,8 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos, dynamic::Value args) {
|
|||
auto id = nextID++;
|
||||
registry.emplace<EntityId>(entity, static_cast<entityid_t>(id), def);
|
||||
registry.emplace<Transform>(entity, pos, size, glm::mat3(1.0f));
|
||||
auto& body = registry.emplace<Rigidbody>(entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
|
||||
auto& body = registry.emplace<Rigidbody>(
|
||||
entity, true, Hitbox {pos, def.hitbox}, std::vector<Trigger>{});
|
||||
for (auto& box : def.triggers) {
|
||||
body.triggers.emplace_back(Trigger{true, id, box, AABB{}, {}, {},
|
||||
[=](auto entityid, auto index, auto otherid) {
|
||||
|
|
@ -140,7 +141,8 @@ void Entities::updatePhysics(float delta) {
|
|||
hitbox.linearDamping = hitbox.grounded * 24;
|
||||
transform.setPos(hitbox.position);
|
||||
if (hitbox.grounded && !grounded) {
|
||||
scripting::on_entity_grounded(*get(eid.uid), glm::length(prevVel-hitbox.velocity));
|
||||
scripting::on_entity_grounded(
|
||||
*get(eid.uid), glm::length(prevVel-hitbox.velocity));
|
||||
}
|
||||
if (!hitbox.grounded && grounded) {
|
||||
scripting::on_entity_fall(*get(eid.uid));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue