Movement scripting...
by Dan Barker · in Torque Game Builder · 10/29/2008 (8:27 pm) · 3 replies
Does any one know how to make a guy move with controlals like Castle Crashers (Xbox Live Arcade game) please. If you do, can you tell me how to.
Thanks,
Dan
Thanks,
Dan
#2
Thanks!
11/07/2008 (5:04 pm)
Thanks, that is what I am looking for. I am trying to work out how to do an attack and will tell you when I work out how to do it.Thanks!
#3
11/11/2008 (10:26 pm)
Well i've worked out a bit of the jump code. still needs alot of work but its a working base. need to add a schedual line in there so that when you hold down the jump command btn that it don't float untill you release it. just gose right back untill you press again. any idea on how to add this? i've tryed putting a 'schedual' in there but i think i'm getting the format wrong.function jumpUp(){
$player.jump("0 -10");
[b]$player.schedule(500, "jumpdown();");}[/b] // this don't work? Y?
function jumpDown(){
$player.jump("0 10");}
function playerclass::jump(%this, %amount){
%position = %this.getPosition();
%newPosition = t2dVectorAdd(%position, %amount);
%this.setPosition(%newPosition);
return %newPosition;}
Torque Owner Alexander \"Xander\" Brown
Bad Production Studio
my Vary Basic Control codes:
Player Class:
function playerclass::onLevelLoaded(%this, %scenegraph) { $Player = %this; // witch keys on the keyboard will preform Witch Movement actions. moveMap.bindCmd(keyboard, "w", "PlayerUp();", "PlayerUpStop();"); moveMap.bindCmd(keyboard, "s", "PlayerDown();", "PlayerDownStop();"); moveMap.bindCmd(keyboard, "a", "PlayerLeft();", "PlayerLeftStop();"); moveMap.bindCmd(keyboard, "d", "PlayerRight();", "PlayerRightStop();"); } // End Load Level Function //------------------------------------------------------------------------------ // Movement Command Key Functions //------------------------------------------------------------------------------ // Telling the Key what it Should Do when Pressed function PlayerUp(){ $Player.moveUp = true; $Player.updateMovement();} function PlayerDown(){ $Player.moveDown = true; $Player.updateMovement();} function PlayerLeft(){ $Player.moveLeft = true; $Player.updateMovement();} function PlayerRight(){ $Player.moveRight = true; $Player.updateMovement();} // Telling the Key what it Should Do when realeased function PlayerUpStop(){ $Player.moveUp = false; $Player.updateMovement();} function PlayerDownStop(){ $Player.moveDown = false; $Player.updateMovement();} function PlayerLeftStop(){ $Player.moveLeft = false; $Player.updateMovement();} function PlayerRightStop(){ $Player.moveRight = false; $Player.updateMovement();} function playerclass::updateMovement(%this) { if(%this.moveLeft){ $Player.setFlipX(true); $Player.setLinearVelocityX( -$Player.HorizonalSpeed );} if(%this.moveRight){ $Player.setFlipX(false); $Player.setLinearVelocityX( $Player.HorizonalSpeed );} if(%this.moveUp){ %this.setLinearVelocityY( -$Player.VerticalSpeed );} if(%this.moveDown){ %this.setLinearVelocityY( $Player.VerticalSpeed );} if(!%this.moveLeft && !%this.moveRight){ %this.setLinearVelocityX( 0 );} if(!%this.moveUp && !%this.moveDown){ %this.setLinearVelocityY( 0 );} }DataBlock for playerdatablock t2dSceneObjectDatablock(PlayerDatablock) { Class = "playerclass"; Layer = "15"; WorldLimitMode = "NULL"; WorldLimitMin = "-50 -37"; WorldLimitMax = "50 37"; WorldLimitCallback = "1"; VerticalSpeed = "15"; HorizonalSpeed = "30"; };that will get you moveing around the screen. i would sugest righting in your animations too if you have them done. (i don't yet...grrr arrrg) if you have any ideas on jump and or attack let me know please..!! (im pritty new to this so. i hope that helps some)