update entity.spawn(...)

This commit is contained in:
MihailRis
2024-06-27 07:50:26 +03:00
parent 94dd69350d
commit 1ca0761f49
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -5,7 +5,8 @@ function on_hud_open()
input.add_callback("player.drop", function ()
local pid = hud.get_player()
local pvel = {player.get_vel(pid)}
local eid = entity.spawn("base:drop")
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
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))