Game Development Community

Top Down Walking Anamation?

by Robert Carroll · in Torque Game Builder · 10/22/2009 (8:36 pm) · 2 replies

Hi I was wondering how I could transform this code (Platformer) into a top down walking anamations. Like take the anamation codes from this and put them on the Truster controls.

if(!isObject(platformerControlsBehavior))
{
   %template = new BehaviorTemplate(platformerControlsBehavior);
   
   %template.friendlyName = "Platformer Tutorial Controls";
   %template.behaviorType = "Input";
   %template.description  = "Movement control for the Platformer Tutorial";
   
   %template.addBehaviorField(jumpKey, "Key to bind to jump movement", keybind, "Space");
   %template.addBehaviorField(leftKey, "Key to bind to left movement", keybind, "Left");
   %template.addBehaviorField(rightKey, "Key to bind to right movement", keybind, "Right");
   
   %template.addBehaviorField(runSpeed, "Speed when running", float, 60.0);
   %template.addBehaviorField(jumpSpeed, "Speed when jumping", float, 150.0);
}
==========TAKEN OUT====================
=======================================
==========TAKEN OUT====================
function platformerControlsBehavior::setCurrentAnimation(%this)
{
	%xVelocity = %this.owner.getLinearVelocityX();
	%yVelocity = %this.owner.getLinearVelocityY();
	
	// Set the flip of the avatar.
	if(%xVelocity > 0)
	{
		
	}
	else if(%xVelocity < 0)
	{
			}
	
	// Animations.
	if(%this.owner.airborne)
	{
		if(%yVelocity < 250)
			%this.owner.playAnimation(playerJumpUp);
		else
			%this.owner.playAnimation(playerJumpDown);
	}
	else
	{
		if(%xVelocity == 0)
		{
				%this.owner.playAnimation(playerWait);
		}
		else
		{
			if(%this.owner.getAnimationName() $= "playerRun")
			{
				if(%this.owner.getIsAnimationFinished())
					%this.owner.playAnimation(playerRun);
			}
			else
				%this.owner.playAnimation(playerRun);
		}
	}
}


==============================================================================
What I would really want to do Is play an anamation when I press a key, then stop it when I let go... It dosnt talk about keys in the code just velocitys.

#1
10/23/2009 (12:03 am)
This may not be exactly what you are looking for, but it may point you in the right direction and give you a very forceful push : )

http://www.garagegames.com/community/resources/view/16693
#2
10/23/2009 (1:41 am)
Ok, thanks I read all that but I can't get much out of it... Im a n00b so thats why but if my anamations name is playerwhat would I write in the feild? it said what but I don't get what im suposed to do :?