Now root motion works much better; raft/boat climbing
This commit is contained in:
@@ -228,13 +228,14 @@ function StartGameQuest()
|
||||
quest.activate = function(this)
|
||||
print('activate...')
|
||||
local mc_is_free = function()
|
||||
this.boat_id = ecs_vehicle_set("raft", 0, 0, -20, 1.75)
|
||||
this.npc_id = ecs_npc_set("normal-female.glb", 0, 2, -20, 1.75)
|
||||
this.boat = true
|
||||
-- ecs_set_slot(this.boat_id, this.npc_id, "captain_seat")
|
||||
-- ecs_character_physics_control(this.npc_id, false)
|
||||
ecs_character_params_set("player", "gravity", true)
|
||||
ecs_character_params_set("player", "buoyancy", true)
|
||||
this.boat_id = ecs_vehicle_set("raft", 0, 0, -10, 1.75)
|
||||
this.npc_id = ecs_npc_set("normal-female.glb", 0, 2, -10, 1.75)
|
||||
this.boat = true
|
||||
-- ecs_set_slot(this.boat_id, this.npc_id, "captain_seat")
|
||||
-- ecs_character_physics_control(this.npc_id, false)
|
||||
local ent = ecs_get_player_entity()
|
||||
ecs_character_params_set(ent, "gravity", true)
|
||||
ecs_character_params_set(ent, "buoyancy", true)
|
||||
end
|
||||
this.story:bind('mc_is_free', mc_is_free)
|
||||
this.base.activate(this)
|
||||
@@ -248,7 +249,128 @@ function StartGameQuest()
|
||||
end
|
||||
return quest
|
||||
end
|
||||
function create_actuator()
|
||||
return {
|
||||
is_complete = false,
|
||||
complete = function(this)
|
||||
return this.is_complete
|
||||
end,
|
||||
finish = function(this)
|
||||
this.is_complete = true
|
||||
ecs_character_set_actuator(this.entity, "")
|
||||
ecs_character_physics_control(this.entity, true)
|
||||
print("COMPLETE")
|
||||
end,
|
||||
forward = function(this)
|
||||
if (this.forward_animation) then
|
||||
this:animation(this.forward_animation)
|
||||
end
|
||||
end,
|
||||
animation = function(this, animation)
|
||||
print("ANIMATION: ", animation)
|
||||
ecs_character_set_actuator(this.entity, animation)
|
||||
end,
|
||||
event = function(this, event, trigger_entity, what_entity)
|
||||
print("actuator events: ", event)
|
||||
if event == "actuator_forward" then
|
||||
this:forward()
|
||||
return true
|
||||
elseif event == "_in_actuator_forward" then
|
||||
this:forward()
|
||||
return true
|
||||
elseif event == "actuator_exit" then
|
||||
this:finish()
|
||||
return true
|
||||
end
|
||||
if this.finish_events then
|
||||
for i, p in ipairs(this.finish_events) do
|
||||
if p == event then
|
||||
this:finish()
|
||||
break
|
||||
end
|
||||
end
|
||||
if this.is_complete then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end,
|
||||
}
|
||||
end
|
||||
quests = {}
|
||||
local actuator = nil
|
||||
function check_actuator_event(event, trigger_entity, what_entity)
|
||||
print("check_actuator_event: ", event)
|
||||
if event == "actuator_enter" then
|
||||
if not ecs_character_is_player(what_entity) then
|
||||
return
|
||||
end
|
||||
ecs_character_physics_control(what_entity, false)
|
||||
local animation = ecs_trigger_get_animation(trigger_entity)
|
||||
ecs_character_set_actuator(what_entity, animation)
|
||||
ecs_trigger_set_position(trigger_entity, what_entity)
|
||||
local ent = ecs_get_entity(what_entity)
|
||||
if (ent.is_character()) then
|
||||
print("character")
|
||||
end
|
||||
if (ent.is_player()) then
|
||||
print("player")
|
||||
end
|
||||
-- crash()
|
||||
actuator = create_actuator()
|
||||
actuator.trigger = trigger_entity
|
||||
actuator.entity = what_entity
|
||||
actuator.forward = function(this)
|
||||
this:animation("swimming-edge-climb")
|
||||
local ent = ecs_get_player_entity()
|
||||
ecs_character_params_set(ent, "gravity", true)
|
||||
ecs_character_params_set(ent, "buoyancy", true)
|
||||
end
|
||||
actuator.base_event = actuator.event
|
||||
actuator.finish_events = {"animation:swimming-edge-climb:end"}
|
||||
actuator.event = function(this, event, te, we)
|
||||
print("actuator events 1: ", event)
|
||||
if this.base_event(this, event, te, we) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
elseif event == "character_enter" then
|
||||
if not ecs_character_is_player(trigger_entity) then
|
||||
return
|
||||
end
|
||||
actuator = create_actuator()
|
||||
actuator.trigger = trigger_entity
|
||||
actuator.entity = trigger_entity
|
||||
actuator.other_entity = what_entity
|
||||
actuator.forward_animation = "pass-character"
|
||||
actuator.finish_events = {"animation:pass-character:end"}
|
||||
actuator.base_event = actuator.event
|
||||
actuator.event = function(this, event, te, we)
|
||||
print("actuator events 2: ", event)
|
||||
if event == "actuator_exit" then
|
||||
this:animation("idle")
|
||||
return true
|
||||
end
|
||||
if this.base_event(this, event, te, we) then
|
||||
return true
|
||||
end
|
||||
if event == "character_enter" then
|
||||
-- why?
|
||||
-- ecs_character_set_actuator(this.entity, "idle")
|
||||
-- ecs_character_set_actuator(this.entity, "idle")
|
||||
return true
|
||||
elseif event == "actuator_enter" then
|
||||
-- why?
|
||||
-- ecs_character_set_actuator(this.entity, "idle")
|
||||
-- ecs_character_set_actuator(this.entity, "idle")
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
actuator:animation("idle")
|
||||
end
|
||||
end
|
||||
-- ecs_set_debug_drawing(true)
|
||||
setup_handler(function(event, trigger_entity, what_entity)
|
||||
print(event)
|
||||
@@ -268,27 +390,27 @@ setup_handler(function(event, trigger_entity, what_entity)
|
||||
local answer = narration_get_answer()
|
||||
print("answered:", answer)
|
||||
elseif event == "new_game" then
|
||||
ecs_character_params_set("player", "gravity", true)
|
||||
ecs_character_params_set("player", "buoyancy", false)
|
||||
local ent = ecs_get_player_entity()
|
||||
ecs_character_params_set(ent, "gravity", true)
|
||||
ecs_character_params_set(ent, "buoyancy", false)
|
||||
local quest = StartGameQuest()
|
||||
quests[quest.name] = quest
|
||||
for k, v in pairs(quests) do
|
||||
print(k, v.active)
|
||||
end
|
||||
quest:activate()
|
||||
elseif event == "actuator_enter" then
|
||||
ecs_character_physics_control(what_entity, false)
|
||||
ecs_character_set_actuator(what_entity, "swimming-hold-edge")
|
||||
ecs_trigger_set_position(trigger_entity, what_entity)
|
||||
local ent = ecs_get_entity(what_entity)
|
||||
if (ent.is_character()) then
|
||||
print("character")
|
||||
else
|
||||
if not actuator then
|
||||
check_actuator_event(event, trigger_entity, what_entity)
|
||||
else
|
||||
if not actuator:event(event, trigger_entity, what_entity) then
|
||||
crash()
|
||||
end
|
||||
if actuator:complete() then
|
||||
print("ACTUATOR COMPLETE")
|
||||
print("EXIT ACTUATOR")
|
||||
actuator = nil
|
||||
end
|
||||
end
|
||||
if (ent.is_player()) then
|
||||
print("player")
|
||||
end
|
||||
-- crash()
|
||||
elseif event == "actuator_exit" then
|
||||
crash()
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user