mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 20:11:50 +00:00
add entity event: on_fall
This commit is contained in:
parent
3946119a67
commit
50c714692a
5 changed files with 39 additions and 10 deletions
|
|
@ -1,11 +1,23 @@
|
|||
inair = true
|
||||
function on_grounded()
|
||||
|
||||
function on_grounded(force)
|
||||
entity.transform:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
|
||||
inair = false
|
||||
end
|
||||
|
||||
function on_update()
|
||||
if inair then
|
||||
entity.transform:set_rot(mat4.rotate(entity.transform:get_rot(), {0, 1, 0}, math.random()*32))
|
||||
end
|
||||
function on_fall()
|
||||
inair = true
|
||||
end
|
||||
|
||||
function on_update()
|
||||
local tsf = entity.transform
|
||||
local body = entity.rigidbody
|
||||
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
|
||||
local dir = vec3.sub({player.get_pos(hud.get_player())}, tsf:get_pos())
|
||||
vec3.normalize(dir, dir)
|
||||
vec3.mul(dir, time.delta()*50.0, dir)
|
||||
--body:set_vel(vec3.add(rigidbody:get_vel(), dir))
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue