Playing animation on keypress.
by William James · in Torque Game Builder · 02/18/2008 (9:23 pm) · 1 replies
I'm just trying to work my way around the TGB reference guide by playing with the different commands trying to figure out what does what? I've trying to get a specific animation to play when a key is pressed but nothing happens with the code below. No errors in script either.
function player::onLevelLoaded(%this, %scenegraph)
{
$ball = %this;
moveMap.bind(keyboard, "space", "playerBounce();");
// try this moveMap.bindCmd(keyboard, "space", "playerBounce();", "playerBounceStop();");
}
//------------------------------------------------------------------------------
// Player stuff
//------------------------------------------------------------------------------
function playerBounce(%this,%val)
{
if(%val)
playAnimation($ball0);
}About the author
Associate Phillip O'Shea
Violent Tulip
function player::onLevelLoaded(%this, %scenegraph) { echo ("Player: " @ %this); echo ("Command: " @ %this @ ".playerBounce();"); moveMap.bindCmd("keyboard", "SPACE", %this @ ".playerBounce();", ""); } function player::playerBounce(%this) { echo ("Animate: " @ $ball0); %this.playAnimation($ball0); }