I’m currently making animation system for group of characters.
Basically, the idea is changing the animation should be as simple as changing the state.
However, the hardest part come when 1 kind of animation can have some variations (i.e. : Idle animation can have idle0, idle1, idle2, etc animation)
my main loop to that group of object is currently look like this
function Update ()
{
var i : int;
if (animState == AnimState.idle)
{
for (i=0; i < go_pike.length; i++)
{
if (! ( go_pike*.animation.IsPlaying("idle1") ||*
go_pike*.animation.IsPlaying("idle2")) )*
_* {*_
_* var type : int = Random.Range(0,2);*_
_* print(i + "'s is "+ type);*_
go_pike*.animation.CrossFadeQueued("idle"+type, 1, QueueMode.PlayNow);*
_* }*_
_* }*_
_* }*_
_* else if (animState == AnimState.run)*_
_* {*_
* for (i=0; i < go_pike.length; i++)*
_* {*_
if (!go_pike*.animation.IsPlaying("run"))*
go_pike*.animation.CrossFade("run");*
_* }*_
_* }*_
_*}*_
_**_
I’ve tried changing CrossFade to CrossFadeQueued, and Play.
Play can work fine, but going from run to idle will be choppy. Same goes for QueueMode.CompleteOthers for CrossFadeQueued
I’ve also tried a semaphore idea and it didn’t work really well (the loop just finish much faster than what I would intend, ergo sending hundreds CrossFadeQueued even the model is still playing. And hence, the most active animation is the most apparent one).
I probably used a wrong approach here, so if someone ever done such animation system/manager, please share me some of your insight
So it actually was the case that your x velocity was 0 and as jmhoubre correctly inferred, 0/0 is NaN (not a number). That's why the internal check failed because you tried to set some internal value to NaN. It's still a mystery why you divide the same value by itself.
– Bunny83