https://github.com/beinteractive/UrMotion
Flexible motion engine for non time-based animation in Unity.
https://github.com/beinteractive/UrMotion
animation tween unity unity3d
Last synced: about 2 months ago
JSON representation
Flexible motion engine for non time-based animation in Unity.
- Host: GitHub
- URL: https://github.com/beinteractive/UrMotion
- Owner: beinteractive
- Created: 2016-03-09T10:25:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-29T01:31:51.000Z (about 7 years ago)
- Last Synced: 2024-11-10T17:45:29.825Z (7 months ago)
- Topics: animation, tween, unity, unity3d
- Language: C#
- Homepage:
- Size: 150 KB
- Stars: 274
- Watchers: 27
- Forks: 28
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-unity3d - UrMotion - A flexible motion engine for non time-based animation in Unity (Open Source Repositories / Animation)
- awesome-unity-open-source-on-github - UrMotion - Flexible motion engine for non time-based animation (Easing)
- awesome-unity3d - UrMotion - A flexible motion engine for non time-based animation in Unity (Open Source Repositories / Animation)
- awesome-unity3d - UrMotion - A flexible motion engine for non time-based animation in Unity (Open Source Repositories / Animation)
README
# A flexible motion engine for non time-based animation in Unity
UrMotion (Your motion) is a brand new simple & flexible motion engine for Unity.
It enables you to create non time-based complex animations on your script easy and fast.To start using UrMotion, copy `Assets/UrMotion` directoy to your project and write `using UrMotion;` in your code.
```C#
using UnityEngine;
using System.Collections;
using UrMotion;
```## Examples
### Simply uniform move
```C#
g.MotionX().Velocity(3f);
```
### Simply uniform move (Moving Y)
```C#
g.MotionY().Velocity(3f);
```
### Simply uniform move (Moving X & Y)
```C#
g.MotionP().Velocity(new Vector2(3f, 2f));
```
### Accel move
```C#
g.MotionX().Accel(0.3f);
```
### Accel move with initial speed
```C#
g.MotionX().Velocity(1f).Accel(0.3f);
```
```C#
g.MotionX().Velocity(-6f).Accel(0.3f);
```
### Accel by ratio
```C#
g.MotionX().AccelByRatio(10f, 0.9f);
```
### Sin move
```C#
g.MotionX().Sin(83f, 0.5f);
```
### Circular move
```C#
g.MotionP().Circular(83f, 0.5f);
```
### Lissajous move
```C#
g.MotionP().Lissajous(83f, 51f, 0.6f, 1.2f, 0f);
```
### Aiming with uniform move
An aiming method produce a velocity that makes a GameObject go toward the specified position.
```C#
g.MotionP().AimAt(p, 10f);
```
### Aiming with common ratio
```C#
g.MotionP().AimRatioAt(p, 0.15f);
```
### Aiming with spring move
```C#
g.MotionP().AimSpringAt(p, 0.15f, 0.8f);
```
### Aiming with exponential interpolation
```C#
g.MotionP().AimExpoAt(p, 0.15f);
```
### Aiming with critically damped spring smoothing
```C#
g.MotionP().AimCriticalDampingAt(p, 0.15f);
```
### Perlin noise
```C#
g.MotionP().Perlin(new Vector2(0.4f, 0.8f)).AmplifyComponents(new Vector2(3f, 2f));
```
### Fractional brownian motion
```C#
g.MotionP().Fbm(new Vector2(0.4f, 0.8f), 3).AmplifyComponents(new Vector2(3f, 2f));
```
### Timed parameter
Change velocity by time with sin curve.
```C#
g.MotionX().Velocity(Source.Float.Sin(2f, 1f).Offset(2f));
```
Change radius by time with sin curve.
```C#
g.MotionX().Sin(Source.Float.Sin(51f, 0.5f).Offset(51f), 1f);
```
### Custom parameter
You can use any of the following types as a motion parameter.
* `V`
* `IEnumerator`
* `IEnumerable`
* `Func``V` is: `float`, `Vector2`, `Vector3` or `Vector4`
```C#
g.MotionX().Velocity(() => Random.Range(-10f, 10f));
```
### Lifetime control
Finish velocity effect after 15fr.
```C#
g.MotionX().Accel(0.3f).Lifetime(15f);
```
Start velocity effect after 15fr.
```C#
g.MotionX().Accel(0.3f).StartDelay(15f);
```
Finish velocity effect if it magnitude is less than 0.01f.
Then, destroy a GameObject.```C#
g.MotionX().AccelByRatio(10f, 0.9f).LiveThreshold(0.01f).Next(() => Destroy(g));
```
## Complex motion examples
### Parabola
```C#
g.MotionX().Velocity(6f);
g.MotionY().Velocity(18f).Accel(-0.98f);
```
### Spiral
```C#
g.MotionP().Circular(Source.Float.Sin(51f, 0.5f).Offset(51f), 2f);
```
### Lissajous + Lissajous
```C#
g.MotionP().Lissajous(83f, 51f, 0.6f, 1.2f, 0f).Lissajous(24f, 32f, 2.4f, 0.8f, 0f);
```
### Lissajous with directon
```C#
var vel = default(IEnumerator);
g.MotionP().Lissajous(83f, 51f, 0.6f, 1.2f, 0f).Capture(out vel);
g.MotionR().AimRatioAt(vel.ToAngle().Offset(-90f), 1f);
```
### Floating scaling
```C#
g.MotionS().AccelByRatio(Vector2.one * 0.4f, 0.85f).Sin(Vector2.one * 0.5f, 0.5f);
```
### Aiming + Ciruclular move
```C#
var vel = default(IEnumerator);
var m = g.MotionP();
m.AimSpringAt(p, 0.1f, 0.45f).Capture(out vel);
m.Circular(vel.Magnitude().Amplify(2f), 2f);
```
### Scaling by velocity
```C#
var vel = default(IEnumerator);
g.MotionP().AimExpoAt(p, 0.15f).Capture(out vel);
g.MotionS().AimSpringAt(vel.Magnitude().Amplify(0.075f).Offset(1f).ToVector2(), 0.12f, 0.7f);
```
### Circular + Noise
```C#
g.MotionP().Circular(83f, 0.25f).Fbm(new Vector2(2f, 3f), 3).Amplify(6f);
```
### Follow move
```C#
Func p = () => GetMousePosition();
g.MotionP().AimCriticalDampingAt(p, 0.8f);
```
### Follow + Circular move
```C#
Func p = () => GetMousePosition();
g.MotionP().AimCriticalDampingAt(p, 0.8f).Circular(83f, 1.5f);
```
### Follow + Follow + Follow
```C#
System.Func gp = () => new Vector2(g.transform.localPosition.x, g.transform.localPosition.y);
g.MotionP().AimCriticalDampingAt(p, 0.8f);
f1.MotionP().AimCriticalDampingAt(gp, 0.3f).StartDelay(6f).AccelByRatio(new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * 20f, 0.9f);
f2.MotionP().AimCriticalDampingAt(gp, 0.2f).StartDelay(9f).AccelByRatio(new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)) * 15f, 0.9f);
```
### Aiming + Noise
```C#
var vel = default(IEnumerator);
var m = g.MotionP();
m.AimSpringAt(p, 0.1f, 0.45f).Capture(out vel);
m.Perlin(new Vector2(7f, 11f)).Amplify(vel.Magnitude().Amplify(1.2f));
```
### Spiral #2
```C#
for (var i = 0; i < 12; ++i) {
g = GameObject.Instantiate(prefab);
g.transform.SetParent(prefab.transform.parent);
g.transform.localPosition = Vector3.zero;
g.transform.localScale = Vector3.one;var angle = 30f * i;
var radius = Velocity.AccelByRatio(218f, Source.Constant(0.92f)).Offset(83f);
var speed = Velocity.AccelByRatio(0.75f, Source.Constant(0.94f)).Offset(0.01f);
g.MotionP().Circular(radius, speed).Angle(angle).Fbm(new Vector2(0f, 1f), 3).AmplifyComponents(new Vector2(0f, 0.3f));
}
```
## License
Copyright 2016 Oink Games, Inc. and other contributors.
Code licensed under the MIT License: http://opensource.org/licenses/MIT