Game Development Community

Call animations

by Rojalee · in Torque Game Engine · 04/11/2007 (3:29 pm) · 8 replies

In Tutorial.base,

How can I call a certain animation froma keystroke?

example: hit key "R" and play the sit animation?

Thanks in advance.

Robert

#1
04/11/2007 (4:04 pm)
I don't know tutorial.base but for starter.fps (and this should give you an idea how to do it):

in default.bind.cs

function sitAnim(%val)
{
	commandToServer('PlayAnim', "sit");
}
moveMap.bind(mouse, button1, sitAnim);

and then in commands.cs

function serverCmdPlayAnim(%client,%anim)
{
   if (isObject(%client.player))
      %client.player.playAnimation(%anim);
}

and in player.cs

function Player::playAnimation(%this,%anim)
{
   if (%this.getState() !$= "Dead")
      %this.setActionThread(%anim);
}
#2
04/11/2007 (4:22 pm)
Datablock TSShapeConstructor(PlayerDts)
{
......
sequence25 = "./player_sitting.dsq sitting";
.......
};

this is the orc in the fps starter kit. default.bind.cs and well as config.cs

moveMap.bindCmd(keyboard, "ctrl w", "commandToServer('playCel',\"wave\");", "");

moveMap.bindCmd(keyboard, "ctrl w", "commandToServer('playCel',\"sitting\");", "");

just changed wave to sitting and you can change the keyboard key's too.
#3
04/12/2007 (6:20 am)
@ mb, ok that way isnt working, I am getting a message in the console that says:
Mapping string: PlayAnim to index: 5
Mapping string: kneel to index: 6

but nothing happens.
function kneel(%val)
{
     commandToServer('PlayAnim', "kneel");
}
moveMap.bind(keyboard, r , kneel);

the second and third block you posted is universal and I inserted exactly as above.

any ideas?
or is there a way to trace exactly what happens when I push r so I can find the error?

@James,
I am going to be adding many different animations, so I'd like to be able to add them all as new, and keep the ones already there.
#4
04/12/2007 (9:45 am)
Rojalee,

I don't believe there is a kneel animation sequence that ships with TGE.
#5
04/12/2007 (10:40 am)
Change 'kneel' to 'sitting' and it should work. I put 'sit' in the code I posted. Sorry, I didnt lookup the name of the animation.
#6
04/13/2007 (3:27 am)
So I can only use the current animations?
I cant add new ones of my own design?
#7
04/13/2007 (6:19 am)
You can certainly add custom designed squences, it's the mighty fulcrum of the NLA system GG is using....:)



Create & Name the new sequence from modelling package[.dsq], load it into the shape at runtime or embedded[.cs], use the name of the sequence in the code as the above illustrate. 'Should' work.

The 'Name' used can be done via the modelling exporter, ooorrrrr...via the TSSConstructor script. I'm not sure if it's still true with 1.5[or your codeBase], but if no 'Name' is given to the sequence via either method; the default is to use the .DSQ File Name, which can be long....;), and unweildy.
#8
04/13/2007 (5:08 pm)
@Rex here is my .cs file. (via MS3D, embedded, and exported as DSQ)

datablock TSShapeConstructor(HumanMaleDts)
{
   baseShape = "./HumanMale.dts";
   sequence0 = "./HumanMale_root.dsq root";
   sequence1 = "./HumanMale_walk.dsq walk";
   sequence2 = "./HumanMale_run.dsq run";
   sequence3 = "./HumanMale_back.dsq back";
   sequence4 = "./HumanMale_side.dsq side";
   sequence5 = "./HumanMale_crawl.dsq crawl";
   sequence6 = "./HumanMale_kneel.dsq kneel";
   sequence7 = "./HumanMale_standjump.dsq standjump";
   sequence8 = "./HumanMale_jump.dsq jump";
   sequence9 = "./HumanMale_swim.dsq swim";
   sequence10 = "./HumanMale_attack.dsq attack";
   sequence11 = "./HumanMale_death.dsq death";

};

And this is from my dump file
Sequences:
        0: Root
        1: walk
        2: run
        3: back
        4: side
        5: crawl
        6: kneel
        7: standjump
        8: jump
        9: swim
       10: attack
       11: death

   Material list:
   material #0: "HumanMale".

so with this being the export, do you see any reason why the above code wouldnt work?