diff --git a/res/content/base/entities/drop.json b/res/content/base/entities/drop.json index c0b8db42..e895490b 100644 --- a/res/content/base/entities/drop.json +++ b/res/content/base/entities/drop.json @@ -1,3 +1,3 @@ { - "hitbox": [0.2, 0.2, 0.2] + "hitbox": [0.2, 0.15, 0.2] } diff --git a/res/content/base/scripts/hud.lua b/res/content/base/scripts/hud.lua index f5bc77ba..d9f27bc0 100644 --- a/res/content/base/scripts/hud.lua +++ b/res/content/base/scripts/hud.lua @@ -8,5 +8,6 @@ function on_hud_open() local eid = entity.spawn("base:drop") local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE) entity.set_vel(eid, vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))) + entity.set_rot(eid, mat4.rotate({0, 1, 0}, math.random() * 360)) end) end diff --git a/src/logic/scripting/lua/libentity.cpp b/src/logic/scripting/lua/libentity.cpp index c66cda80..fae0054b 100644 --- a/src/logic/scripting/lua/libentity.cpp +++ b/src/logic/scripting/lua/libentity.cpp @@ -45,9 +45,25 @@ static int l_set_vel(lua::State* L) { return 0; } +static int l_get_rot(lua::State* L) { + if (auto entity = get_entity(L, 1)) { + return lua::pushmat4(L, entity->getTransform().rot); + } + return 0; +} + +static int l_set_rot(lua::State* L) { + if (auto entity = get_entity(L, 1)) { + entity->getTransform().rot = lua::tomat4(L, 2); + } + return 0; +} + const luaL_Reg entitylib [] = { {"spawn", lua::wrap}, {"get_vel", lua::wrap}, {"set_vel", lua::wrap}, + {"get_rot", lua::wrap}, + {"set_rot", lua::wrap}, {NULL, NULL} }; diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index 0b83b52c..6d886afc 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -46,9 +46,9 @@ void Entities::updatePhysics(float delta){ 1.0f, true ); - hitbox.linear_damping = hitbox.grounded * 5; + hitbox.linear_damping = hitbox.grounded * 12; transform.pos = hitbox.position; - transform.rot = glm::rotate(glm::mat4(transform.rot), delta, glm::vec3(0, 1, 0)); + //transform.rot = glm::rotate(glm::mat4(transform.rot), delta, glm::vec3(0, 1, 0)); if (hitbox.grounded) { //hitbox.velocity.y = 10; }