add base:player_animator component

This commit is contained in:
MihailRis
2024-07-23 22:55:34 +03:00
parent b23f7e996f
commit e8a8fb3d60
5 changed files with 39 additions and 4 deletions
+3
View File
@@ -1,3 +1,6 @@
{
"components": [
"base:player_animator"
],
"hitbox": [0.6, 1.8, 0.6]
}
+1 -1
View File
@@ -28,7 +28,7 @@ end
do -- setup visuals
local matrix = mat4.idt()
scale = item_models.setup(dropitem.id, rig)
scale = item_models.setup(dropitem.id, rig, 0)
local bodysize = math.min(scale[1], scale[2], scale[3]) * DROP_SCALE
body:set_size({scale[1] * DROP_SCALE, bodysize, scale[3] * DROP_SCALE})
mat4.mul(matrix, rotation, matrix)
@@ -0,0 +1,27 @@
local item_models = require "core:item_models"
local tsf = entity.transform
local body = entity.rigidbody
local rig = entity.skeleton
local itemid = 0
local itemIndex = rig:index("item")
local function refresh_model(id)
if id == 0 then
rig:set_model(itemIndex, "")
else
itemid = id
local scale = item_models.setup(itemid, rig, itemIndex)
rig:set_matrix(itemIndex, mat4.scale(scale))
end
end
function on_render()
local invid, slotid = player.get_inventory()
local id, _ = inventory.get(invid, slotid)
if id ~= itemid then
refresh_model(id)
end
end
+4
View File
@@ -9,6 +9,10 @@
"name": "head",
"model": "player-head",
"offset": [0, 0.4, 0]
},
{
"name": "item",
"offset": [0.26, 0, -0.23]
}
]
}