Game Development Community

Key bindings

by abhinav · in Torque Game Engine · 10/26/2012 (5:34 am) · 10 replies

Default.bind.cs is used for key bindings like wave( keyboard,w) but if i had to play another animations to player like swing what files will be edited and how to play anim

#1
10/26/2012 (8:52 am)
If you have a license for TGE ( Torque Game Engine ) there is the documents with the installation and / or from the Account download page you can get the documentation as a download.

If the documents fail to answer your questions in TGE then you can shop at Amazon.com for this book www.amazon.com/Game-Programmers-Guide-Torque-GarageGames/dp/1568812841/ref=sr_1_... which is still relevant to much of TGE.
There is a companion book: www.amazon.com/Multiplayer-Gaming-Engine-Coding-Torque/dp/1568814224/ref=sr_1_7?... for making Multiplayer games with TGE, as well.
#2
10/26/2012 (9:12 am)
Sorry your idea's not working i had these books under my belt any genius who solve this riddle
#3
10/26/2012 (9:23 am)
i think there is 2 way.


function func(%a)
{
playActionThread("mySwingAnimation");
}


movemap.bind(w,func)

i am not near my pc.so not sure about bind() and playActionThread()'s parameter.look for correct prototype in manual.



or
u can rename "wave" animation to something else and then rename "swing" animation as "wave".but it is just a chiting. better go with 1st one
#4
10/26/2012 (9:45 am)
Your 2 cheat work 1 example freeze screen sorry not correct 1 one
#5
10/26/2012 (9:45 am)
If you have the books, open it to the Index.
Start in letter "A".
Find the line that reads " Action Maps " as the first entry of the Index.
You'll be in Chapter 9 section 9.4.1

You'll see this:

9.4.1 Defining Action Maps
"To create a new ( blank ) action map, we use the following syntax ( explained in Table 9.2)."

Start there and when you're done, go through the rest of the Index at letter " A " for the rest of your answers.
You can also open the *.cs files with any text editor to see working examples of assigning an animation to a keybind ( provided you have the animation made ).

Some members may choose to answer you with a code example... I chose instead to show you where your answers are.
This reduces misunderstanding of examples and possible typo errors. It also helps you to get a firm grasp of the entire concept of how and why it's done, rather than just the answer.. thus.. you'll be a genius and you'll be here answering other members on how to do the same thing.
#6
10/26/2012 (9:58 am)
My torque engine crash because of wrong coding
i got one example in my book see
function test(%val)
{
if(%val)
echo("key is down");
else
echo("key was released");
}
//bind the 't' key to the test function
movemap.bind(keyboard, "t", test);
#7
10/26/2012 (10:14 am)
What was that mapping string: playcel to index : 3
#8
10/26/2012 (10:32 am)
moveMap.bind( keyboard, a, moveleft );
moveMap.bind( keyboard, d, moveright );
moveMap.bind( keyboard, w, moveforward );
moveMap.bind( keyboard, s, movebackward );

movemap: function that swaps the current actionmap for the new actionmap.
.bind: member function of movemap that does the actual placement of values into the new actionmap.

keyboard: the input device being used.
a: the key we want to assign
moveleft: the animation we want to use when we press the letter "a" on the keyboard to be bound to the new actionmap.

Each line above is assigning a keyboard key to an animation.
The result will be the animation will play when the button is pressed.
But the book you have will explain in detail, the how and why.
The book explains the function and it's purpose.

moveleft, moveright, moveforward, movebackward, are all names of the animations.
The book explains all you need to understand the concept. So, even if your bad at explaining things in words ( as I am ).. you'll at least understand the how and why.. then you'll be able to just write the code you need.

There are no members in this community that can give you a written example for you to copy and paste, without first seeing what you have written already and what animations you have available so they can spell your animation correctly.
This is why I explained where to get your answer from the documentation, or books, or in your own code examples that are supplied with the engine.

Showing you how to get an answer is far better than simply giving you the answer.

An example of what I mean would be to give you the answer to a Trigonometry question without explaining how I got the answer. But, if I show you where,how, and why I got the answer, then you'll be able to solve the math on your own.
#9
10/26/2012 (10:42 am)
"1 example freeze screen sorry not correct 1 one "


my mistake.
as far i remember playActionThread() have no effect on player character .
u have to use setActionThread().
but setActionThread have to be applied on player object.

i am not near my pc so cannot give u full code.
if u can find out how to get player object pointer in script then can easily do that.
or wait for someone's code example.


correct one would be something like this:

function func(%a)
{
%playerObject=???????
if(%a)
%playerObject.setActionThread("mySwingAnimation");
}


u better find out how wave animation is playing.
look for it in Default.bind.cs then copy paste.
assign a new key and then replace wave animation field with swing animtion name.
#10
10/26/2012 (11:20 am)
Its is not so easy as mentioned but doing hard work spend nights like batman make it easier