Sign in to follow this  
vinnyvicious

Unity Using perlin noise for subtle random animation/motion

Recommended Posts

vinnyvicious    692

After reading the documentation of the very nice Ultimate FPS add-on for Unity, i've decided to try something similar in my own camera control. Right now, my camera is pretty basic and just puts a weapon model in front of it. I've successfully added some "damping" effect by calculating the weapon "weight"... when you move, there's a slight motion to the weapon model, like this:

 

https://www.youtube.com/watch?v=ay2SMb9-nEE

 

In UFPS, they explain other concepts for procedural animation:

 

https://docs.google.com/document/d/17Ns3PwlSWg4kqWwnBZ4DRa9n_LMSOe7m3KzMfsPUGBI/pub?embedded=true#h.69r4j1rrvafw

 

However, i have no idea how to apply a standard noise function to produce idle animation. Should i just apply it randomly to the entire transformation matrix of the model? Including rotation? How would you approach this?

 

Also, since i'm trying to do most of the animations in code, and just use a plain model without animation, which kind of noise/curve would you guys use for creating the shooting animation? I tried using a https://en.wikipedia.org/wiki/Lissajous_curve but it feels very weird, works better for sniper scopes only.

Share this post


Link to post
Share on other sites
ApochPiQ    23061
There are many options. It all depends on what you think feels good and looks right.

For example, you could take simple 1D noise values and "nudge" the model's local orientation on each axis, using 3 different samples. Over time, increment the input value used to sample the noise curves, and you should get a smooth oscillation. This will be easy to implement but probably not look great.

A better-looking result would probably come from using a 3D noise field. Using the current anchor/root point of the model, sample the noise field's derivative in 3-space. Follow the derivative some distance (how far you go will affect how "fast" the weaving looks) and update the root point (or look-at vector) based on that location. Over time, slide the 3D noise field around a bit (or rotate it) and you should get a nice organic-looking effect.

[edit]
For the firing animation, take some time to study how real firearms look when discharging. YouTube has tons of footage of this kind of stuff, for example. You'll notice that the majority of movement is backwards toward the wielder, and some random amount vertically with a tiny bit of extra side-to-side displacement based on how sloppy the shooter is. So you can take aim-point of the weapon, nudge it vertically a small amount, and add a tiny left or right shift, then slerp back to ready position. Done. Edited by ApochPiQ

Share this post


Link to post
Share on other sites
ApochPiQ    23061
No.


Given a point at {X, Y, Z} with a noise value of N (typically from 0 to 1) there is a 3-dimensional vector D, composed of {X' Y' Z'} where each of X' Y' and Z' are partial derivatives with respect to a specific axis of the noise function itself.

Start with the point at the look-at vector's tip for the model. Using the values of the partial derivatives, construct the vector {X' Y' Z'} and normalize it. Then scale it by some customized distance factor, up to you, play with it. Follow that vector to get to a point we'll call P. Draw a vector from the root of the model through P. Update the model transform to orient the look-at vector to aim towards P.



If you're not up on your multivariate calculus, don't worry about trying to implement this ;-) Edited by ApochPiQ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this