Water Size Animation

It's possible to animate the water size in code using the method AnimateWaterSize(targetSize, duration, constraint, wrapMode).

  • targetSize: [Vector2] sets the water target size.
  • duration: [float] sets the animation duration in seconds.
  • constraint: [enum WaterAnimationConstraint] constraints the position of one/multiple water edge(s)

    WaterAnimationConstraint enum

    None, Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight

    • wrapMode: [enum WaterAnimationWrapMode]

    WaterAnimationWrapMode enum

    • Once: Stops playing the animation once the target size is reached.
    • Loop: The water size is reset to the initial size and the animation is restarted once the target size is reached.
    • PingPong: When the target size is reached, the initial size is set to the new target size and the animation restarts. So the water size will ping-pong back and forth between the initial size and the target size.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using Game2DWaterKit.Animation;

....

var targetSize = waterObject.MainModule.WaterSize + new Vector2(0f, 3f); // increase the water height by 3 units
var duration = 2f; // 2 seconds
var constraint = WaterAnimationConstraint.Bottom; // constraints the position of the bottom edges, so only the top edge "moves"
var wrapMode = WaterAnimationWrapMode.Once; // play the animation once

waterObject.AnimationModule.AnimateWaterSize(targetSize, duration, constraint, wrapMode);