add modeltree:get_matrix, :set_matrix

This commit is contained in:
MihailRis
2024-07-02 22:13:16 +03:00
parent 8a10ed24da
commit 42ea88501d
7 changed files with 53 additions and 18 deletions
+11 -3
View File
@@ -5,8 +5,14 @@ local rig = entity.modeltree
inair = true
ready = false
local rotation = mat4.rotate({0, 1, 0}, math.random() * 360)
mat4.rotate(rotation, {1, 0, 0}, math.random() * 360, rotation)
mat4.rotate(rotation, {0, 0, 1}, math.random() * 360, rotation)
rig:set_matrix(0, rotation)
function on_grounded(force)
tsf:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
rig:set_matrix(0, mat4.rotate({0, 1, 0}, math.random()*360))
inair = false
ready = true
end
@@ -25,7 +31,9 @@ end
function on_update()
if inair then
local dt = time.delta();
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 1, 0}, 240*dt))
tsf:set_rot(mat4.rotate(tsf:get_rot(), {0, 0, 1}, 240*dt))
local matrix = rig:get_matrix(0)
mat4.rotate(matrix, {0, 1, 0}, 240*dt, matrix)
mat4.rotate(matrix, {0, 0, 1}, 240*dt, matrix)
rig:set_matrix(0, matrix)
end
end
-2
View File
@@ -16,8 +16,6 @@ function on_hud_open()
local drop = entities.spawn("base:drop", ppos)
drop.rigidbody:set_vel(vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
drop.transform:set_rot(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)
end