add radial triggers
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"hitbox": [0.2, 0.125, 0.2],
|
||||
"triggers": [
|
||||
["aabb", -0.2, -0.2, -0.2, 0.2, 0.2, 0.2]
|
||||
["aabb", -0.2, -0.2, -0.2, 0.2, 0.2, 0.2],
|
||||
["radius", 1.6]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ local rig = entity.modeltree
|
||||
|
||||
inair = true
|
||||
ready = false
|
||||
target = -1
|
||||
|
||||
local dropitem = ARGS.item
|
||||
local scale = {1, 1, 1}
|
||||
@@ -60,11 +61,20 @@ function on_fall()
|
||||
end
|
||||
|
||||
function on_trigger_enter(index, oid)
|
||||
if ready and oid == 0 then
|
||||
if ready and oid == 0 and index == 0 then
|
||||
entity:despawn()
|
||||
inventory.add(player.get_inventory(oid), dropitem.id, dropitem.count)
|
||||
audio.play_sound_2d("events/pickup", 0.5, 0.8+math.random()*0.4, "regular")
|
||||
end
|
||||
if index == 1 and ready and oid == 0 then
|
||||
target = oid
|
||||
end
|
||||
end
|
||||
|
||||
function on_trigger_exit(index, oid)
|
||||
if oid == target and index == 1 then
|
||||
target = -1
|
||||
end
|
||||
end
|
||||
|
||||
function on_update()
|
||||
@@ -79,4 +89,10 @@ function on_update()
|
||||
mat4.scale(matrix, scale, matrix)
|
||||
rig:set_matrix(0, matrix)
|
||||
end
|
||||
if target ~= -1 then
|
||||
local dir = vec3.sub({player.get_pos(target)}, tsf:get_pos())
|
||||
vec3.normalize(dir, dir)
|
||||
vec3.mul(dir, 10.0, dir)
|
||||
body:set_vel(dir)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,6 @@ function on_hud_open()
|
||||
local pvel = {player.get_vel(pid)}
|
||||
local ppos = vec3.add({player.get_pos(pid)}, {0, 0.7, 0})
|
||||
local throw_force = vec3.mul(player.get_dir(pid), DROP_FORCE)
|
||||
|
||||
local drop = entities.spawn("base:drop", ppos, {item={
|
||||
id=itemid,
|
||||
count=1
|
||||
|
||||
Reference in New Issue
Block a user