Game Development Reference
In-Depth Information
Adding transitions
Adding transitions to the ASM is very similar to adding states, except that we need to
check and make sure that the ASM contains the states we are transitioning to. Transitions
are stored in a manner that is very similar to states, except that they are stored in a two-di-
mensional table based on their from state and their to state :
Sandbox.lua :
function AnimationStateMachine.AddTransition(
self, fromStateName, toStateName, blendOutWindow,
duration,
blendInWindow)
if (self:ContainsState(fromStateName) and
self:ContainsState(toStateName)) then
local transition = AnimationTransition.new();
transition.blendOutWindow_ =
blendOutWindow or transition.blendOutWindow_;
transition.duration_ = duration or
transition.duration_;
transition.blendInWindow_ =
blendInWindow or transition.blendInWindow_;
if (self.transitions_[fromStateName] == nil) then
self.transitions_[fromStateName] = {};
end
self.transitions_[fromStateName][toStateName] =
transition;
end
end
Search WWH ::




Custom Search