Giter Site home page Giter Site logo

tweenmachine's Introduction

Logo160

TweenMachine

A minimal, action-based tween utility for Unity

What does action-based mean?

With TweenMachine all tweening is done through an update action called onUpdate. This action has a single parameter: an eased value that represents how complete the tween is. What you do with that value is up to you; it's perfect for feeding into Unity's Lerp and Slerp functions.

TweenMachine does not have functions to move, rotate, scale, fade, set colors, manage objects, fold laundry, etc. You do everything yourself, in the onUpdate and onComplete functions.

This is better for you (because you don't have to trawl through documentation to find out how to do something), and it's better for me (because I don't have to write the documentation).

Features

  • Single file
  • Open source, MIT license, on GitHub
  • Function-oriented interface
  • Nice selection of easings
  • Option to chain tweens

Typical use

Add the using:

using TweenMachine;

Then, somewhere:

// make the tween
var tween = transform.Tween(this);
tween.duration = 0.75f;
tween.easing = Easing.Quadratic;
tween.easingDirection = EasingType.easeInOut;

// define what the tween is doing
var startPosition = transform.localPosition;
var endPosition = new Vector3(0, 0, 100);

// create the update callback
tween.onUpdate = (t) =>
{
	// t ranges from 0.0f to 1.0f over the duration of the tween
	transform.localPosition = Vector3.LerpUnclamped(startPosition, endPosition, t);
};

The tween component is added and immediately starts running, and destroys itself after calling onComplete.

Easing Options

TweenMachine offers the following types of easing, as described at https://easings.net/

  • Linear
  • Quadratic
  • Cubic
  • Quartic
  • Quintic
  • Sine
  • Circular
  • Exponential
  • Elastic
  • Back
  • Bounce

These easings can be applied as

  • In
  • Out
  • In-Out

tweenmachine's People

Contributors

cosmo7 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.