Game Development Community

Animation (When it feels like it)??

by Aidan Sliney · in Technical Issues · 08/19/2008 (4:16 am) · 17 replies

I have a bot

it has 4 animations

"root" "forward" "point" "Talk"

All animations work in show tools.
All Animations work when I put bot in as Static object


THE PROBLEM:

I put the bot following a path.

Sometimes when i load up the game the animations work, he is happy out walking along path.

The next time I load the game none of the animations work. He is floating along the path.

I havn' t touched anything in between.

How can this be??

#1
08/19/2008 (6:39 am)
That's odd...post the data/shapes/player/player.cs file here. Also, in server/scripts/player.cs, make sure the line exec("~/data/shapes/player/player.cs"); is up there. That loads the file I want you to post, which includes the data for making sure the sequences are included with the player. A floating bot means that he isn't getting the sequence data to know that he's animated. Have you moved any directories or made a new player model or datablock? Have you made any changes to aiPlayer.cc in the engine code?
#2
08/19/2008 (7:55 am)
If you are using the standard player class, it expects a number of animations as well as some specific nodes.

This may be causing the errors you are having.
#3
08/19/2008 (7:57 am)
datablock PlayerData( MyBot)
{
   patrol = true;
   attack = false;
   maxForwardSpeed = 2;
   shapeFile =  "~/data/shapes/builder_skinny/builder_skinny.dts";
};




function MyBot::onReachDestination( %this, %obj )
{
	if( %obj.path !$= "" )
	{
		if( %obj.currentNode == %obj.targetNode )
			{
			%this.onEndOfPath( %obj, %obj.path );
			echo("my bot on reach");
			}
		else
			%obj.moveToNextNode();
	}
	else
		echo( "MyBot::onReachDestination warning - Path is blank!" );
}

function MyBot::onEndOfPath( %this, %obj, %path )
{
	%obj.nextTask();
	bot4.playThread(0,"Root");
	echo("my bot onEnd");

}


//-----------------------------------------------------------------------------
// AIPlayer static functions
//-----------------------------------------------------------------------------

function AIPlayer::spawn( %name, %spawnPoint )
{
	// Create the A.I. driven bot object...
	%player = new AIPlayer()
	{
		dataBlock = $datablock;
		path = "";
	};

	MissionCleanup.add( %player );
	%player.setShapeName( %name );
	%player.setTransform( %spawnPoint );

	return %player;
}

function AIPlayer::spawnOnPath( %name, %path )
{
	// Spawn a bot and place him on the first node of the path
	if( !isObject( %path ) )
	{
		echo( "AIPlayer::spawnOnPath failed - Bad Path!" );
		%this.path = "";
		return;
	}

	%node = %path.getObject(0);
	%player = AIPlayer::spawn( %name, %node.getTransform() );

	return %player;
}

function AIPlayer::followPath( %this, %path, %node )
{

	if( !isObject( %path ) )
	{
		echo( "AIPlayer::followPath failed - Bad Path!" );
		%this.path = "";
		return;
	}

	if( %node > %path.getCount() - 1 )
		%this.targetNode = %path.getCount() - 1;
	else
		%this.targetNode = %node;

	if( %this.path $= %path )
		%this.moveToNode(%this.currentNode);
	else 
	{
		%this.path = %path;
		%this.moveToNode(0);
	}
}

function AIPlayer::moveToNextNode( %this )
{
	if( %this.targetNode < 0 || %this.currentNode < %this.targetNode )
	{
		if( %this.currentNode < %this.path.getCount() - 1 )
			%this.moveToNode( %this.currentNode + 1 );
		else
			%this.moveToNode( 0 );
	}
	else
	{
		if( %this.currentNode == 0 )
			%this.moveToNode( %this.path.getCount() - 1 );
		else
			%this.moveToNode( %this.currentNode - 1 );
	}
}

function AIPlayer::moveToNode( %this, %index )
{
   // Move to the given path node index
   %this.currentNode = %index;
   %node = %this.path.getObject(%index);
   %this.setAimLocation(%node.getTransform());
   %this.setMoveDestination( %node.getTransform(), %index == %this.targetNode );
}

function AIManager::spawn( %this )
{ 
    	$datablock = MyBot;
        %bot4 = AIPlayer::spawnOnPath( "Bot_4", "MissionGroup/myPath2" );
	%bot4.followPath( "MissionGroup/myPath2", -1 );
    	%bot4.setName(bot4);
    	bot4.playThread(0,"forward");
   return %bot;
}



the above code works

The problem is that the bot only uses the "forward" animation sometimes???????
#4
08/19/2008 (7:57 am)
P.S
The four animations are embedded into the Dts file.
#5
08/20/2008 (3:09 am)
Any ideas???
#6
08/20/2008 (4:50 am)
Sometimes if an animation that is not looping comes to a stop, then you will have to issue a start on the thread before it starts playing ie. your forward animation. I'm not even sure I'm right about this, because I did not investigate further yet. But if this helps I'm glad. Try to see which is the last animation that is correctly executed.
#7
08/20/2008 (5:49 am)
Check to make sure your forward, back, and side animations are set to cyclic so they loop when finished. Otherwise, they will play once and the player floats
#8
08/20/2008 (7:18 am)
The forward animation is looped.


8 times out of 10 when i run the simulator he works perfectly.


The 2 times he floats, even if i type:

bot4.playThread(0,"forward");

into the console, he will not animate. it is as if the thread is broken or something???
#9
08/20/2008 (12:07 pm)
By 'floats' I assume you mean assumes the default pose you exported the dts with? If so, then code is attempting to play an animation this model doesn't have. Because it's only after a time, then some condition has changed, and now pickActionAnimation() has taken over. Since your bot is still a derivative of player, there are a few hardcoded animations that WILL be called at some point.
A quick prooftest would be to load the bot with all the standard player animations. Now what move is he doing when your regular calls stop working?
#10
08/21/2008 (9:52 am)
Isn't the "forward" animation supposed to be called "run" in Torque? That's what I use with my models, works every time.
#11
08/25/2008 (6:54 am)
You need and another basic animation... the "side"
Without side animation the bot in side step move,
if the aim of bot is targeting on a oblique direction not raning but slide for 1 markerpath to another.
Statement add in your model the 4 basic anims (root, run, back, side)
#12
08/25/2008 (7:51 am)
++bryce++ my "forward" animation in my max sequence is labelled "forwar"


++Dimitris++

Very interesting. Do you need these four Animations (root, run, back, side) for a bot also??
#13
08/25/2008 (7:59 pm)
Yes for all bots and players. This 4 is the basics for torque and working auto without programing.
If you are using ebbeded sequences try to rename in 4 basics.
If not the name is not necessary. In player.cs or botxxx.cs the "forwar" or any else name determine as "run"
etc. sequence1 = "./thief_forward.dsq run";
Some extra for bots like fight, speek, block is good idea...

if a sequence is custom for many bots or players use the external method, is more easy :)
#14
08/30/2008 (5:56 am)
If you're lazy, like me, you can have more than one dsq use the same animation
sequnce1 = "./marine_forward.dsq run";
sequence2 = "./marine_forward.dsq side";
sequence3 = "./marine_forward.dsq back";
#15
09/01/2008 (2:18 am)
C i don't use dsq's for my bots i embed the animations into the dts
#16
09/01/2008 (6:29 am)
Aha! There's the problem! Characters use a wide variety of animations, and some require blending. When you embed animations into the dts, there is no blending, which may or may not screw up the rest of the animations. I would definitely try splitting your sequences into dsq's. Are you using milkshape?
#17
09/01/2008 (10:57 am)
Also, you may want to include the look animation, the engine may be trying to play it on the bot when it doesn't exist.