Player animations
by Henry Garle · in Torque Game Engine Advanced · 10/05/2007 (4:08 pm) · 3 replies
Ive been playing around with this for a while now but i cant seem to crack it.
I changed the playcelanimation function slightly to read like this:
function Player::playAnimation(%this,%anim)
{
%this.setActionThread(%anim);
}
And then a commandtoserver reading like this:
function serverCmdPlayAnim(%client,%anim)
{
if (isObject(%client.player))
%client.player.playAnimation(%anim);
}
And my player.cs file:
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./player.dts";
sequence0 = "./TM_Adam_root.dsq root";
sequence1 = "./TM_Adam_idle.dsq idle";
sequence2 = "./TM_Adam_rootDamage_1.dsq rootdamage" ;
.................
...............
...........
sequence56 = "./TM_Adam_walkDamaged_1.dsq walkD1";
sequence57 = "./TM_Adam_walkDamaged_2.dsq walkD2";
sequence58 = "./TM_Adam_walkDamaged_4.dsq walkD4";
sequence59 = "./TM_Adam_crouchWalk.dsq crouchW";
};
Ive tryed calling it every way i can think of but i cant seem to get it work.
How would i go about triggering certian animations? Such as a wave animation that is in there somewhere.
Thanks,
Henry
I changed the playcelanimation function slightly to read like this:
function Player::playAnimation(%this,%anim)
{
%this.setActionThread(%anim);
}
And then a commandtoserver reading like this:
function serverCmdPlayAnim(%client,%anim)
{
if (isObject(%client.player))
%client.player.playAnimation(%anim);
}
And my player.cs file:
datablock TSShapeConstructor(PlayerDts)
{
baseShape = "./player.dts";
sequence0 = "./TM_Adam_root.dsq root";
sequence1 = "./TM_Adam_idle.dsq idle";
sequence2 = "./TM_Adam_rootDamage_1.dsq rootdamage" ;
.................
...............
...........
sequence56 = "./TM_Adam_walkDamaged_1.dsq walkD1";
sequence57 = "./TM_Adam_walkDamaged_2.dsq walkD2";
sequence58 = "./TM_Adam_walkDamaged_4.dsq walkD4";
sequence59 = "./TM_Adam_crouchWalk.dsq crouchW";
};
Ive tryed calling it every way i can think of but i cant seem to get it work.
How would i go about triggering certian animations? Such as a wave animation that is in there somewhere.
Thanks,
Henry
About the author
#2
E.G:
sequence59 = "./TM_Adam_crouchWalk.dsq crouchW";
Is that right?
Thanks for the help!
10/05/2007 (8:19 pm)
Yeah i was trying the command through console for the time being I Didnt actualy change the function, jsut used it as a base. So "Death1" Is the name at the end of the animation?E.G:
sequence59 = "./TM_Adam_crouchWalk.dsq crouchW";
Is that right?
Thanks for the help!
#3
10/05/2007 (8:23 pm)
Ok, its all working now and i have no idea why it wasnt before. A few hours off and 5 mins back seems to have solved the problem! Thanks alot.
Torque 3D Owner Mark Dynna
commandToServer('PlayAnim', "death1");Then you'll probably want to place that inside another client-side function so you can bind it to the "down" keystroke of some keyboard combination, so it will look like this in your client\scripts\default.bind.cs :function tryDeath(%val) { if(%val) commandToServer('PlayAnim', "death1"); }; moveMap.bind(keyboard, "alt d", tryDeath);It's a little hard to get your head around at first but this is how the sequence works.
Keypress calls a function -> function send command to server -> server receives command -> calls member function of the Player object.
This is all necessary because the Server contains the "real" copy of the Player object, and only it is "authorized" to force the Player object to do things, like play animations.