AnimationBlender dies when blend called between transitions

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
Contact:

AnimationBlender dies when blend called between transitions

Post by Danoli3 » Mon Nov 23, 2009 9:08 am

Heyyo,

I have noticed that the AnimationBlender dies/freezes (the animation not the application) when the blend function is called between the transition time of the last blend.
I am specifically talking about "BlendWhileAnimating" state here.

I have tested many things like removing a lot of code from the AnimationBlender itself and I still have been unsuccuessful in fixing this without causing a thousand more.

Source code:
http://www.ogre3d.org/wiki/index.php/An ... changes.29


My problem:
When my character walks if they stop pressing a directional key the animation is called for "Idle" using the BlendWhileAnimating, (see below)
the problem arises from the user then pressing a directional key (which calls blend to "Run") within the time of the transition. (say 0.5 seconds in my game).
It basically freezes the characters animation state.

Example of the blend code

Code: Select all

if(isRunning)
pAnimationBlender->blend("Run", AnimationBlender::BlendWhileAnimating, 0.5, true );
if(!isRunning)
pAnimationBlender->blend("Idle", AnimationBlender::BlendWhileAnimating, 0.5, true );
Temporary solutions I can think of:
Have a timer to count for the transition time between animations and do not allow a blend between this time and have a stack that when the time is up it will call whatever state was set to next in my own code.


I have no idea why the animation blender as it stands fails like this in the transition time. It works perfectly otherwise.
I've had my teacher and peers look through and they all agree its the animation blender not my code, but no one can pin point the problem either :P
Now its up to you Ogre3derer's :D!

Can you find the problem?

-Dan
0 x
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009

User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
Contact:

Re: AnimationBlender dies when blend called between transitions

Post by Danoli3 » Wed Nov 25, 2009 4:20 am

I implemented the work around I said above and this does work. Still for the transition time the entity will continue with its last animation. Still this looks better than freezing the animation for and endless time until the next animation is called.

If anyone has this problem I suggest using that work around ... or finding the bug within the animation blender code :P

-Dan
0 x
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009

User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
Contact:

Re: AnimationBlender dies when blend called between transitions

Post by Danoli3 » Wed Nov 25, 2009 4:27 am

Heres is an example of what this code looks like (modified for hopefully better understanding)

When an initial movement or stop occurs:

Code: Select all

if (isRunning)	// if the actor is already walking skip this
    {
			if(!isTransition)
			{
				pAnimationBlender->blend("Run", AnimationBlender::BlendWhileAnimating, 0.5, true );
				theState = transToRun;
				theTargetState = transToRun;
				isTransition = true;
			}
			else			
				theTargetState = transToRun;
    }
else if(!isRunning)
    {

                       if(!isTransition)
			{
				pAnimationBlender->blend("Idle", AnimationBlender::BlendWhileAnimating, 0.5, true );
				theState = transToIdle;
				theTargetState = transToIdle;
				isTransition = true;
			}
			else			
				theTargetState = transToIdle;

    }

The update:

Code: Select all

if(isTransition)
	{
		time += deltaTimeSecs;		
		if(time > 0.5)
		{
			isTransition = false;
			time = 0;
		}
	}

	if(!isTransition && theState != theTargetState)
	{
	
		switch(theTargetState)
		{
			case transToRun:
			{
				pAnimationBlender->blend("Run", AnimationBlender::BlendWhileAnimating, 0.5, true );
				theState = transToRun;
				theTargetState = transToRun;
				isTransition = true;
				break;
			}
			case transToIdle:
			{
				pAnimationBlender->blend("Idle", AnimationBlender::BlendWhileAnimating, 0.25, true );
				theState = transToIdle;
				theTargetState = transToIdle;
				isTransition = true;
				break;
			}
		
		}

	}

The header delcartions:

Code: Select all

enum blendTime{
		transToIdle,
		transToRun,
		transToJump,
		transToAttack,
		isNormal
	};
	blendTime theState;
	blendTime theTargetState;
        Ogre::Real time;
	bool isTransition;
-Dan
0 x
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009

User avatar
Danoli3
Halfling
Posts: 53
Joined: Wed Jul 29, 2009 8:25 am
Location: Sydney, Australia
Contact:

Re: AnimationBlender dies when blend called between transitions

Post by Danoli3 » Wed Nov 25, 2009 4:37 am

Posted this info on the Wiki ;)
0 x
Studying BSc in Games Development @ the University of Technology of Sydney Australia
Ogre Projects so far: Mall Rush
Finished a Diploma in Games Development 2009

Post Reply