Skip to content

Commit 5f73f74

Browse files
authored
Update README.md
1 parent a2af1c5 commit 5f73f74

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
11
# Unity Animation Modifiers
2+
Provides ways to use equations to change values in the Unity editor over time, similar to animation modifiers in Blender or scripting in AfterEffects.
3+
## Features
24

3-
A library for adding animation modifiers to unity similar to animation modifiers in Blender or scripting in AfterEffects.
5+
- Can affect any float value accessible in the Unity editor
6+
- Can either modify values by overwriting them or by non-destructively adding to them
7+
- Modifiers are applied after all other scripts, so they won't overwrite or be overwritten by changes that other scripts make
8+
- Support for Sine and Perlin Noise functions, as well as custom animation curves and written equations
9+
- Framework for creating your own custom modifiers
10+
11+
## The Float Animation Modifier
12+
In order to use an Animation Modifier, you need to attach a FloatAnimationModifier to an object in your scene. It will contain several fields:
13+
14+
- Sync On Awake: Should the time used in the modifier be synced with Time.realtimeSinceStartup?
15+
- Modifier Type: What type of modifier do you want to use to generate your value? The options are:
16+
- Noise: Generate values using a perlin noise function, which will give random values with smooth transitions between them
17+
- Sine: Generate values using a sine wave
18+
- Custom Curve: Generate values using an animation curve drawn in-editor
19+
- Custom Equation: Generate values using an equation you type into a text box
20+
- Custom: Use a modifier script that you wrote yourself
21+
22+
Depending on the type of modifier you pick, you will get slightly different settings. However, all modifiers share an 'Additive' tickbox, which lets you pick whether you want the value from the modifier to be added on top of the original value, and an 'Intensity' value, which the modified value is multiplied by before it is returned.
23+
24+
All modifiers also share a 'Float Accessor' field, which allows you to select the value that you want to modify. [You can find more information on Accessors here.](https://github.com/dninosores/UnityValueAccessors)
25+
26+
### Periodic Settings
27+
Noise, Sine, and Custom Curve are all periodic modifiers, meaning that they can be scaled over time. When you have one of these modifiers selected, you will have access to the Periodic Settings menu, which contains four settings:
28+
29+
- Amplitude: The maximum value that the modifier can reach
30+
- Frequency: The speed at which the modified value changes (in Hz)
31+
- Phase shift: How much the modifier should be offset over time
32+
- Vertical shift: A constant value to be added to the modifier
33+
34+
### Custom Equations
35+
When using custom equations, you should type the equation you want to use without an '='. You can use "t" to refer to the time since the modifier was started in seconds. Some examples of equations that you could use are:
36+
37+
- t + 1
38+
- sin(t)
39+
- (10 * t) ^ 5
40+
- Noise(10,t) * 6
41+
42+
The modifier uses the [mxparser](https://github.com/mariuszgromada/MathParser.org-mXparser) library to read equations, so any functions supported in that library will be supported here.
43+
Additionally, you can use Noise(seed, time) to generate random Perlin noise in the same way that the Noise modifier does.
44+
45+
## Creating your own modifiers
46+
If you want to create your own custom modifier, there are two routes you can take:
47+
### Custom Float Modifier
48+
In order to create a custom modifier that works with float modifiers, you should create a script that extends the CustomFloatModifier class, attach that script to a GameObject in your scene, and reference that script on a FloatAnimationModifier that has been set to 'Custom' mode.
49+
50+
### Custom Modifiers for Other Data Types
51+
In order to create a modifier for a non-float value, you will need to extend the Modifier<T\> class. Make sure that you mark your class as Serializable or it won't show up in the Unity editor. Since Modifiers aren't MonoBehaviours, they cannot be attached to GameObjects as scripts. In order to actually use your modifier in your scene, you will need to extend the MonoAnimationModifier class, which acts as a MonoBehaviour wrapper that you can use to attach your modifier to GameObjects.
52+
53+
When creating custom modifiers, you will most likely find [Accessors](https://github.com/dninosores/UnityValueAccessors) useful for creating references to the values that you want to modify.
54+
55+
## Installation
56+
Download or clone this repository and place it in the Assets folder of your Unity project.
57+
58+
## Dependencies
59+
This library requires you to have the [UnityValueAccessors](https://github.com/dninosores/UnityValueAccessors) and [UnityEditorAttributes](https://github.com/dninosores/UnityEditorAttributes) libraries in your project Assets folder.

0 commit comments

Comments
 (0)