Game Development Community

Adventure Toy Movements

by Greyfort · in Torque 2D Beginner · 04/27/2014 (7:45 pm) · 3 replies

Edited 05.06.2014
//------------------------------------------------------------------------------------------------------------

NEW Issues::

Q1: Ware might I find some info on creating cross pad and buttons... or do I just make my own gui and controls and call mouse down?

Q2: how do I get TS to play animation once.

Q3: I cant seem to get this code to work in T2DMit... can we get postion in T2DMit i'm not finding in documents?

%origin=%this.owner.getPostion();
	%x=%origin.x;
	%y=%orign.y;


Q4: It only plays the last if statement animation, I need it to play anim for each direction.

function ShooterControlsBehavior::zKey(%this, %val)
{

if( $direction == $dup )
	{
	%this.owner.anim = "Zqrk:lqrk_z_nAnimation"; 
	    %this.z = %val;
    %this.updateMovement();
	}
	
if(  $direction == $dright )
	{
	%this.owner.anim = "Zqrk:lqrk_z_eAnimation"; 
	    %this.z = %val;
    %this.updateMovement();
	}
	
if(  $direction == $dleft )
	{
	%this.owner.anim = "Zqrk:lqrk_z_wAnimation"; 
	    %this.z = %val;
    %this.updateMovement();
	}

if(  $direction == $ddown )
	{
	%this.owner.anim = "Zqrk:lqrk_z_sAnimation"; 
	    %this.z = %val;
    %this.updateMovement();
	}
}


//------------------------------------------------------------------------------------------------------------

Please help me, find resource to learn better on the T2DMit, I'm eager to use it but finding it frustrating.

Here is link to my Repository:: github.com/Greyfort/T2DMit_Adventure_RPG_Toy
So you can view and test out all script.

//------------------------------------------------------------------------------------------------------------
Old issues can be found in postings below

#1
04/28/2014 (9:41 am)
As a tip, it helps with readability on the forum if you surround your scripts with code tags.

I know it can get frustrating when scripts don't work as they should. Try to approach debugging logically and make lots of use of the console.

For instance here, if flipping is working but movement is not, then the keybindings are working and you are getting to the updateMovement function. The code for making an object move is here:

%this.owner.setLinearVelocityX((%this.right - %this.left) * %this.horizontalSpeed);
%this.owner.setLinearVelocityY((%this.up - %this.down) * %this.verticalSpeed);

You're setting the velocity by taking a 1 or -1 value from the keyboard presses and multiplying it by a speed value. The problem is here:
//%template.addBehaviorField(verticalSpeed, "Speed when moving vertically", float, 20.0);
//%template.addBehaviorField(horizontalSpeed, "Speed when moving horizontally", float, 20.0);

The fields for speed have been commented out so without values assigned to vertical and horizontalSpeed, you don't have movement.
#2
05/01/2014 (5:06 pm)
old Issue::
//----------------------------------------
if (!isObject(ShooterControlsBehavior))
	{
    %template = new BehaviorTemplate(ShooterControlsBehavior);

    %template.friendlyName = "ShooterControls";
    %template.behaviorType = "Input";
    %template.description  = "Shooter style movement control";

    %template.addBehaviorField(upKey, "Key to bind to upward movement", keybind, "keyboard up");
    %template.addBehaviorField(downKey, "Key to bind to downward movement", keybind, "keyboard down");
    %template.addBehaviorField(leftKey, "Key to bind to left movement", keybind, "keyboard left");
    %template.addBehaviorField(rightKey, "Key to bind to right movement", keybind, "keyboard right");

    //%template.addBehaviorField(verticalSpeed, "Speed when moving vertically", float, 20.0);
    //%template.addBehaviorField(horizontalSpeed, "Speed when moving horizontally", float, 20.0);
	}

I used this tutorial example so others understand what movement will be. My issue is my sprite just flips east n west and does not move around screen. I want it to move like an adventure game if pc moves west it plays anim adds to screen position to create movement on screen. I must be misunderstanding something...

I am trying to make a zelda1 type Adventure Toy (movements actions, attak actions etc )for others to learn, yet have found I'm really going to be learning allot. I thought I understood the shooter scripting and see I have not.

Thanks for the help Mike... Here is FIXED CODE For any and all who might need it.

#3
05/06/2014 (2:04 am)
Have Moved old issues below Added new issue to main post Above.