Simple but subtly powerful behavior for doing eased interpolation between two points. Easing means the transition is smooth when close to the endpoints. This functionality is similar to the sine behavior but additional properties, expressions and actions make it more powerful.
Get the plugin here (ZIP)
The naive use of the behavior is to make an object "ping-pong" between two points.
Origin X,Origin Y
Destination X,Desitnation Y
- time taken to complete the transition
- Move easing into (EaseIn)
end of transition is smoothed
- Move easing away (EaseOut)
beginning of transition is smoothed
- Move easing both (EaseInOut)
both beginning and end of transition are smoothed
All three actions work in ping-pong fashion alternately
from call to call (first action called will go origin-to-dest, second destination-to-origin, third origin-to-destination, and so forth).
Call the action will no-op if a movement is already in place. The time lerp is independant of the position so changing the position should not lead to any sort of runaway object (non halting movement). The time lerp will clamp if out of bounds to the property setting if you mess with the transition period mid-movement. Do not set the transition period to exactly zero as it is sure to stop your game due to divide-by-zero (time fraction is calculated as current_elapsed/transition_period). Maybe there is a way to have the transition_period property reject any change that sets it exactly zero? I'm not quite sure how to go about it.
- Change origin endpoint
Allows changing the origin endpoint at any time,
- Change destination endpoint
Allows changing the destination endpoint at any time,
- Change transition period
Allows changing the transition period to any nonzero value.
Changing mid transition may cause clamping and snaps to return
the values to the new range but it should not crash the game.
The endpoint actions can be used to do waypoint type movements or any sort of complicated pattern of bumps, shakes, etc. of an object.
Three conditions may be used for event to know the state of the transition:
object is at "ping"
object is at "pong"
- Is in transition (invertible to mean "Is stationary")
object is moving (or inverted: not moving)
Expression for events:
1 if object is moving otherwise 0
(expression form of Is in transition)
Returns the status of transition
result is a float in range 0 to 1 inclusive
0 matches IsAtOrigin condition
1 matches IsAtDestination
A more powerful feature is to use this expression
to apply something other than movement to the object
(eg: Set angle to -180*myObject.GauVeldt_Ease.GetTransition)
- On Endpoint Reached
fires when object completes movement cycle
Condition IsAtDestination/IsAtOrigin may be used in
subevent or GetTransition may be used to know which
endpoint the object is at
- On Update Tick
this one is subtly very powerful as it provides the ideal
trigger upon which to add actions using GetTransition to set
other object properties (eg: visible, angle, etc). Sure
you could do it in System:OnEveryTick but I think this is
cleaner in practice (a system event would need a whole bunch
of sub events to test the location, movement status, etc)
I think that's everything. One final possible improvement is to allow customization of the transition functions (there are three) EaseIn for the start of a transition, EaseOut for the end of a transition and EaseInOut for both. Right now the transition functions are internal but it could perhaps be modified to accept JS expressions in string properties using eval to compile to functions. That's for future consideration.
PS: To do eased rotations or fades, etc., with no movement just set the origin and destination to the same point as its layout position. A TODO item is to add a movement-ignore flag for just these kinds of non-movement transitions.
Added Set Origin, Set Destination, and Set Period actions for changing the movement location via event sheet actions.