update entity.spawn(...)
This commit is contained in:
parent
94dd69350d
commit
1ca0761f49
@ -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))
|
||||
|
||||
@ -24,10 +24,10 @@ static std::optional<Entity> get_entity(lua::State* L, int idx) {
|
||||
|
||||
static int l_spawn(lua::State* L) {
|
||||
auto level = controller->getLevel();
|
||||
auto player = hud->getPlayer();
|
||||
auto defname = lua::tostring(L, 1);
|
||||
auto& def = content->entities.require(defname);
|
||||
auto id = level->entities->spawn(def, player->camera->position);
|
||||
auto pos = lua::tovec3(L, 2);
|
||||
auto id = level->entities->spawn(def, pos);
|
||||
return lua::pushinteger(L, id);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user