• entries
24
53
• views
34241

2428 views

[font=verdana]

# The inception

[/font]
[font=verdana]A while back, after slowly becoming mad tweaking animations and movement behavior on our avatar, I decided to have some simple fun with Unity. See where the limit was and what's possible in a certain domain. Since I was obsessed with the character's animation, my attention was driven towards improving what our animator gave us in terms of natural movement. Even though the animations were quite good, I wanted some physics madness in there. So I went on a quest to mess with the bones of mecanim.
It turns out it's rather straightforward to activate the so called "jiggly bones". A few changes in your model before export does the trick. It does however require a great deal of value tweaking and physics engine know-how. You may follow this tutorial if you want to try it for yourself.
Here's what I could do as a quick 'n dirty test. This will *not* be in the game. Even if the effect could be nice, It is at the bottomest bottom of our priorities.[/font]

[font=verdana][/font]

[font=verdana]But doing this as a playful "what if" helped me learn a lot about how Unity works with animations and physics. Even better, I would never have thought of what I'm about to show if I hadn't gamed the system.
A few days later, the movement and animation finally polished, I found one last thing I could do, turn the head of the fox in the direction of where the avatar will go next. Providing a subconscious feedback on the movement. Using the head bone and overriding the animation, it should be possible. Right?[/font]

[font=verdana][/font]

[font=verdana]It turns out it is. This gif was taken when a bug prevented the fox to move or turn so you can clearly see that the head orientation is overridden (and a bit disturbing, sorry).

# How to do it

[/font]

[indent=1][font=verdana]

## [color=rgb(51,51,51)]First, you have to get a reference to your head bone:[/color]

[/font]
private void Awake(){ HeadBone = /*find the headbone in the hierarchy*/.transform;}
[indent=1][font=verdana]

## [color=rgb(51,51,51)][color=rgb(51,51,51)]There's nothing to do to your model. All you have to do is use the LateUpdate function which is called afterthe internal update of the animations.[/color][/color]

[/font]
private void LateUpdate(){ Quaternion look_at = Quaternion.LookRotation(Direction, new Vector3(0.0f, 1.0f, 0.0f)); look_at *= Quaternion.Euler(-90.0f, 0.0f, 0.0f); // Our models are rotated HeadBone.rotation = look_at;}
[indent=1][font=verdana][color=rgb(51,51,51)]You can do all sorts of crazy stuff with this.[/color][/font]

[font=verdana][color=rgb(51,51,51)]

### # The result

[/color][/color][/color][/font]

[font=verdana][color=rgb(51,51,51)]

### [color=rgb(51,51,51)]

[/color][/color][/color][/font]

[font=verdana]

## [color=rgb(51,51,51)][color=rgb(51,51,51)][color=rgb(51,51,51)]Here you can see the result in game. Slowed down on purpose to make sure it's seeable in a gif. The effect is very subtle but you can see that the head will always point to the right direction (almost instantly) and the body follows soon after.The next time you are frustrated with a particular task or simply bored out of your mind after a day of repetitive tweaks. Do yourself a favor and just play with the tools on your workbench. Who knows what kind of gem you'll unearth.[/color][/color][/color]

[/font]

### Images

View the entire Epistory album

Another nice entry. I like where this is going.

"(and a bit disturbing, sorry)" Disturbing is my middle name!

This looks very nice. Keep up the good work.

## Create an account

Register a new account