Перейти к основному содержимому

Как принудительно запустить анимацию НПС?

Вопрос

Как принудительно запустить анимацию НПС?

Ответ

Для принудительного запуска анимации НПС можно использовать следующий код функции внутри логики:

```lua
function reset_npc_animation (actor, npc, p)
local npc_obj
if (p and p[1] ~= nil) then
npc_obj = get_story_object(p[1])
elseif (npc ~= nil) then
npc_obj = npc
else
return
end
local state_mgr = db.storage[npc_obj:id()].state_mgr
if state_mgr == nil then
return
end
local planner = npc_obj:motivation_action_manager()
state_mgr.animation:set_state(nil, true)
state_mgr.animation:set_control()
state_mgr.animstate:set_state(nil, true)
state_mgr.animstate:set_control()
state_mgr:set_state("idle", nil, nil, nil, { fast_set = true })
state_mgr:update()
state_mgr:update()
state_mgr:update()
state_mgr:update()
state_mgr:update()
state_mgr:update()
npc_obj:set_body_state(move.standing)
npc_obj:set_mental_state(anim.free)
end

В вашем случае функцию можно использовать следующим образом:

[logic]
active = remark
[remark]
anim = wait
on_info = {+xxx} %=reset_npc_animation%
remark@2
anim = hide