Chapter 5.9: Creating Visuals - The Animations Module
Want to make an object smoothly fade out, change color, or move from one point to another? The Animations module handles this for you, calculating all the intermediate steps to create a fluid animation.
Example: A fading, color-changing platform.
This script is on a trigger_multiple. When the player steps on it, a platform turns red and then fades out.
function OnStartTouch() {
local platform = entLib.FindByName("fade_platform")
if (platform) {
// Animate the color from its current color to solid red over 1 second.
animate.ColorTransition(platform, platform.GetColor(), "255 0 0", 1.0)
// Animate the alpha (transparency) from full (255) to invisible (0) over 3 seconds.
// The animation will start after a 1-second delay.
local settings = { globalDelay = 1.0 }
animate.AlphaTransition(platform, 255, 0, 3.0, settings)
}
}
This module also includes functions for animating position (PositionTransitionByTime, PositionTransitionBySpeed) and angles (AnglesTransitionByTime).