Urho.Actions Namespace

Action framework for Node used to animate or change properties in an Node.

Remarks

You can add behavior to nodes very easily using Actions.   Actions are immutable objects, which allows you to reuse the action for driving different objects.  

Actions operate on nodes usually over a period of time, and you can use them to move, rotate, scale, fade, change their color or visibility, place or remove and to control some simple looping behavior.   To control the rate of change, you can use easing actions to wrap other actions and control precisely the timing and effect of the actions they wrap.

You trigger an action on a node by invoking the Node.RunActionsAsync method.  If you use this in combination with C# await, the method will only return after the action has completed.   If you do not, the action will execute and your code will continue running.

For example, consider a “cloud” node on your scene, you can fade it like this:

C# Example

await cloud.RunActionsAsync (new FadeOut (duration: 3))

The above would fade lineraly the node for three seconds.

A common idiom is to create an action that performs the reverse operation:

C# Example

var gotoExit = new MoveTo (duration: 3, position: exitLocation);
var return = gotoExit.Reverse ();

You can also run one action after another by passing more than one action to Node.RunActionsAsync, for example, you could first move the cloud, and then fade it away:

C# Example

await cloud.RunActionsAsync (
  new MoveBy  (duration: 1.5f, position: new Vector3(0, 0, 15),
  new FadeOut (duration: 3));

If you want both actions to take place at the same time, you can use the Parallel action, and provide all the actions you want done in parallel:

C# Example

await cloud.RunActionsAsync (
  new Parallel (
    new MoveBy  (duration: 3, position: new Vector3(0, 0, 15),
    new FadeOut (duration: 3)));

This is a list of the available actions:

Easing Actions

Easing is a way that directs the way that the animation will unfold, and it can make your animations a lot more pleasant. By default your actions will have a linear behavior, for example a MoveTo action would have a very robotic movement. You can wrap your Actions into an Easing action to change the behavior, for example, one that would slowly start the movement, accelerate and slowly reach the end (EasyInOut).

You do this by wrapping an existing Action into an easing action, for example:

C# Example

await cloud.RunActionAsync (
  new EaseInOut (
    new MoveTo (duration: 3, position: new Vector (0,0,15)), rate:1))

There are many easing modes, the following chart shows the various easing types and their behavior on the value of the object they are controlling over the period of time, from start to finish:

Creating your own Actions

The easiest thing to do is to subclass one of the variosu existing actions and add your own behavior to it. Each Action is a recipe that describes declaratively what will happen. These recipes can be created and then executed on different nodes. When the action is actually started, the BaseAction.StartAction method is invoked. This method needs to create an instance of a subclass of ActionState that will record the state and perform the actual action on each time tick.

Classes

TypeReason
ActionEaseBase class for all the Action Easing functions.
ActionEaseStateEncapsulates the running state for the ActionEaseState action.
ActionInstantBase class for actions that have an immediate effect.
ActionInstantStateEncapsulates the running state for the ActionInstantState action.
ActionManagerThe manager for all executing actions.
ActionStateEncapsulates the states of a running action.
ActionTagEnumeration used to tag actions, the only interesting value is the field “Invalid” which is used to tell the tag apart from user-set tags.
ActionTween
ActionTweenStateEncapsulates the running state for the ActionTweenState action.
AmplitudeAction
AmplitudeActionStateEncapsulates the running state for the AmplitudeActionState action.
BaseActionBase class for actions in Urho.
BezierBySets the position of the node to follow a specified bezier path.
BezierByStateEncapsulates the running state for the BezierByState action.
BezierConfigBezier path configuration using two control points and an end position.
BezierToSets the position of the node to follow a specified bezier path.
BezierToStateEncapsulates the running state for the BezierToState action.
BlinkBlinks a node by setting its Enabled state.
BlinkStateEncapsulates the running state for the BlinkState action.
CallFuncInvokes an Action on every Action Update tick.
CallFuncNInvokes an System.Action<Urho.Node> on every Action Update tick, passing the node where the action is taking place.
CallFuncNDInvokes an System.Action<Urho.Node,System.Object> on every Action Update tick, passing the node where the action is taking place and a specified data payload.
CallFuncNDStateEncapsulates the running state for the CallFuncNDState action.
CallFuncNStateEncapsulates the running state for the CallFuncNState action.
CallFuncOInvokes an System.Action<System.Object> on every Action Update tick, passing  a specified data payload.
CallFuncOStateEncapsulates the running state for the CallFuncOState action.
CallFuncStateEncapsulates the running state for the CallFuncState action.
DelayTimeAn action which completes after the specified time.
DelayTimeStateEncapsulates the running state for the DelayTimeState action.
EaseBackInEasing function: back in.
EaseBackInOut
EaseBackInOutStateEncapsulates the running state for the EaseBackInOutState action.
EaseBackInStateEncapsulates the running state for the EaseBackInState action.
EaseBackOutEasing function: back out.
EaseBackOutStateEncapsulates the running state for the EaseBackOutState action.
EaseBounceInEasing function: bounce in.
EaseBounceInOutEasing function: bounce in and out.
EaseBounceInOutStateEncapsulates the running state for the EaseBounceInOutState action.
EaseBounceInStateEncapsulates the running state for the EaseBounceInState action.
EaseBounceOutEasing function: bounce out.
EaseBounceOutStateEncapsulates the running state for the EaseBounceOutState action.
EaseCustomCustom easing function using a function that provides the easing values.
EaseCustomStateEncapsulates the running state for the EaseCustomState action.
EaseElasticBase class for elastic easing actions.
EaseElasticIn
EaseElasticInOut
EaseElasticInOutStateEncapsulates the running state for the EaseElasticInOutState action.
EaseElasticInStateEncapsulates the running state for the EaseElasticInState action.
EaseElasticOut
EaseElasticOutStateEncapsulates the running state for the EaseElasticOutState action.
EaseElasticStateEncapsulates the running state for the EaseElasticState action.
EaseExponentialIn
EaseExponentialInOut
EaseExponentialInOutStateEncapsulates the running state for the EaseExponentialInOutState action.
EaseExponentialInStateEncapsulates the running state for the EaseExponentialInState action.
EaseExponentialOut
EaseExponentialOutStateEncapsulates the running state for the EaseExponentialOutState action.
EaseIn
EaseInOut
EaseInOutStateEncapsulates the running state for the EaseInOutState action.
EaseInStateEncapsulates the running state for the EaseInState action.
EaseOut
EaseOutStateEncapsulates the running state for the EaseOutState action.
EaseRateActionBase class for easing actions that have an easing rate component.
EaseRateActionStateEncapsulates the running state for the EaseRateActionState action.
EaseSineIn
EaseSineInOut
EaseSineInOutStateEncapsulates the running state for the EaseSineInOutState action.
EaseSineInStateEncapsulates the running state for the EaseSineInState action.
EaseSineOut
EaseSineOutStateEncapsulates the running state for the EaseSineOutState action.
FadeInFades-in the StaticSprite2D component or Shape component of a Node.
FadeInStateEncapsulates the running state for the FadeInState action.
FadeOutFades-out the StaticSprite2D component or Shape component of a Node.
FadeOutStateEncapsulates the running state for the FadeOutState action.
FadeToAlters the alpha component of the StaticSprite2D component or Shape component of a Node.
FadeToStateEncapsulates the running state for the FadeToState action.
FiniteTimeActionBase class for actions that have a time duration.
FiniteTimeActionStateEncapsulates the running state for the FiniteTimeActionState action.
HideHides a node.
HideStateEncapsulates the running state for the HideState action.
JumpBy
JumpByStateEncapsulates the running state for the JumpByState action.
JumpTo
JumpToStateEncapsulates the running state for the JumpToState action.
MoveBy
MoveByStateEncapsulates the running state for the MoveByState action.
MoveTo
MoveToStateEncapsulates the running state for the MoveToState action.
Parallel
ParallelStateEncapsulates the running state for the ParallelState action.
PlaceSets the position of a node.
PlaceStateEncapsulates the running state for the PlaceState action.
RemoveSelfRemoves the node from its container (another node)
RemoveSelfStateEncapsulates the running state for the RemoveSelfState action.
Repeat
RepeatForever
RepeatForeverStateEncapsulates the running state for the RepeatForeverState action.
RepeatStateEncapsulates the running state for the RepeatState action.
ReverseTime
ReverseTimeStateEncapsulates the running state for the ReverseTimeState action.
RotateAroundBy
RotateAroundByStateEncapsulates the running state for the RotateAroundByState action.
RotateBy
RotateByStateEncapsulates the running state for the RotateByState action.
RotateTo
RotateToStateEncapsulates the running state for the RotateToState action.
ScaleBy
ScaleByStateEncapsulates the running state for the ScaleByState action.
ScaleTo
ScaleToStateEncapsulates the running state for the ScaleToState action.
Sequence
SequenceStateEncapsulates the running state for the SequenceState action.
ShaderParameterColorFromTo
ShaderParameterFloatFromTo
ShaderParameterFromTo<TShaderParamType>
ShaderParameterFromToState<TShaderParamType>
ShaderParameterVector2FromTo
ShaderParameterVector3FromTo
ShaderParameterVector4FromTo
ShowShows a node.
ShowStateEncapsulates the running state for the ShowState action.
Spawn
SpawnStateEncapsulates the running state for the SpawnState action.
Speed
TargetedAction
TargetedActionStateEncapsulates the running state for the TargetedActionState action.
TintBy
TintByStateEncapsulates the running state for the TintByState action.
TintTo
TintToStateEncapsulates the running state for the TintToState action.
ToggleVisibilityToggles the visibility of a node.
ToggleVisibilityStateEncapsulates the running state for the ToggleVisibilityState action.