Skip to content

Instantly share code, notes, and snippets.

@AliFlux
Last active April 24, 2017 13:54
Show Gist options
  • Save AliFlux/038cd43ef690308c72a67c7f32e49507 to your computer and use it in GitHub Desktop.
Save AliFlux/038cd43ef690308c72a67c7f32e49507 to your computer and use it in GitHub Desktop.
Fluent Animation Community Post

Fluent Animation - Animate and queue almost anything without headaches.

[picture]

A new fluent way to solve the decade old problem of queuing animations pretty easily. A simple example:

Animating a simple GameObject

Fluent.Animation.New()
  .With(gameObject)
  .MoveTo(new Vector3(0, 100, 0), 3f)
  .RotateTo(Quaternion.Euler(0, 90, 30), 3f);

So what happened here? Well, the New() method created a new animation. The With method made sure that all next animations are applied to the given gameObject. The MoveTo and RotateTo functions animated the position and rotation of the gameObject, one after the other in 3 seconds.

The animations were queued. The rotation occured after the movement, and that's the beauty of procedural/fluent scripting.

Some of the features:

  • Move, rotate, scale almost anything
  • Execute animations in parallel
  • Comes with 31 easing effects
  • Support for custom easing effect
  • Animate objects on a set of way points
  • Animate custom components
  • Animate custom fields/properties
  • Extend class to add more features
  • Customize animation update type
  • Loop, control, or jump to specific animation
  • Bezier, Spline and Linear waypoint paths
  • Comes with 5 free easy to learn demos

[couple of screenshots]

Animating custom components or properties

Fluent gives the ability to animate almost anything we like. Let's try animating a customProperty of a CustomComponent.

Fluent.Animation.New()
  .AnimateProperty(gameObject.GetComponent<CustomComponent>(), 'customProperty', 20f, 30f, 2f)

This will animate the customProperty from 20f to 30f in 2 seconds. This code also works on built-in components and properties. AnimatePropertyBy can be used if you don't want to specify the starting value.

Animating an object on a path

[screenshot of promo]

Fluent comes with native support for animating objects on any path. Best part? The path could be either bezier, spline, or linear. Let me show you:

[screenshot of differences]

Online documentation and examples

https://gist.github.com/AliFlux/7c40bda68f08930b554cf754d896b600

So why was this created?

I was designing Extreme Air Combat game last year, and it was pretty difficult/verbose for me to create cut-scenes in which there are several moving objects one after another. And even more of a headache in which there are a few parallel animations involved. So I designed this thing to help me develop my game with less headches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment