add entity event: on_grounded

This commit is contained in:
MihailRis
2024-06-28 12:47:45 +03:00
parent eb2be5e8b6
commit e0e5faa4a8
7 changed files with 24 additions and 6 deletions
+4
View File
@@ -5,3 +5,7 @@ end
function on_despawn(eid)
print("despawn", eid)
end
function on_grounded(eid)
Transform.set_rot(eid, mat4.rotate({0, 1, 0}, math.random()*360))
end
+3 -1
View File
@@ -9,6 +9,8 @@ function on_hud_open()
local eid = entity.spawn("base:drop", ppos)
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
Rigidbody.set_vel(eid, vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
Transform.set_rot(eid, mat4.rotate({0, 1, 0}, math.random() * 360))
Transform.set_rot(eid,
mat4.rotate(mat4.rotate(mat4.rotate({0, 1, 0}, math.random() * 360),
{1, 0, 0}, math.random() * 360), {0, 0, 1}, math.random() * 360))
end)
end