add triggers

This commit is contained in:
MihailRis
2024-06-30 16:25:08 +03:00
parent 50c714692a
commit 5769be8ec8
15 changed files with 239 additions and 64 deletions
@@ -0,0 +1,28 @@
local tsf = entity.transform
local body = entity.rigidbody
inair = true
ready = false
function on_grounded(force)
tsf:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
inair = false
ready = true
end
function on_fall()
inair = true
end
function on_trigger_enter(index, oid)
if ready then
entity:despawn()
end
end
function on_update()
if inair then
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 1, 0}, math.random()*12))
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 0, 1}, math.random()*12))
end
end