Game Development Community

Player animations determined by weapon (almost works) (help?)

by Dan Keller · in Torque Game Engine · 11/22/2007 (8:22 pm) · 16 replies

Basically the image datablock gets a playerSequenceOffset variable that determines which "set" of dsqs the player uses. For example, my player.cs looks like
datablock TSShapeConstructor(PlayerDts)
{
   baseShape = "./models/player.dts";
   //////////////////////////////////////standard
   sequence0 = "./anims/root.dsq Root";
   sequence1 = "./anims/run.dsq Run";
   sequence2 = "./anims/back.dsq back";
   sequence3 = "./anims/run.dsq side";
   sequence4 = "./anims/fall.dsq fall";
   sequence5 = "./anims/jump.dsq jump";
   sequence6 = "./anims/jump.dsq Standjump";
   sequence7 = "./anims/land.dsq land";
   sequence8 = "./anims/root.dsq look";
   sequence9 = "./anims/head.dsq head";
   ////////////////////////////////////////M1A1
   sequence10 = "./anims/m1_root.dsq Root_M1";
   sequence11 = "./anims/m1_run.dsq Run_M1";
   sequence12 = "./anims/m1_back.dsq back_M1";
   sequence13 = "./anims/m1_run.dsq side_M1";
   sequence14 = "./anims/m1_root.dsq fall_M1";
   sequence15 = "./anims/m1_jump.dsq jump_M1";
   sequence16 = "./anims/m1_jump.dsq Standjump_M1";
   sequence17 = "./anims/m1_root.dsq land_M1";
   sequence18 = "./anims/m1_look.dsq look_M1";
   sequence19 = "./anims/head.dsq head_M1";
   /////////////////////////////////////////Browning
   sequence20 = "./anims/br_root.dsq Root_Br";
   sequence21 = "./anims/br_run.dsq Run_Br";
   sequence22 = "./anims/br_back.dsq back_Br";
   sequence23 = "./anims/br_run.dsq side_Br";
   sequence24 = "./anims/br_root.dsq fall_Br";
   sequence25 = "./anims/br_jump.dsq jump_Br";
   sequence26 = "./anims/br_jump.dsq Standjump_Br";
   sequence27 = "./anims/br_root.dsq land_Br";
   sequence28 = "./anims/br_look.dsq look_Br";
   sequence29 = "./anims/head.dsq head_Br";
   /////////////////////////////////////////misc
   sequence30 = "./anims/death_1.dsq death1";
};

So the offset for the M1 is 10, the offset for the Browning 9mm is 20, etc.

The files needed are:
player.h
player.cc
shapeBase.h
shapeImage.cc

#1
11/22/2007 (11:25 pm)
Does the animation look right when you switch back? If so, this may be a problem with the second set of animations. You need to put 'ground transform' into the animation so that Torque knows how fast your character is supposed to be going in the animation. When it figures that out, it an speed up or slow down the animation depending on how fast the character is actually going.
#2
11/23/2007 (7:52 am)
The odd thing is, before picking up a weapon, it sometimes look right. I can start moving and the animation won't play, but then stop and start again and it will.
#3
11/25/2007 (7:59 pm)
Well, I figured out the problem. There's a little piece of code in updateMove that checks if the player is moving and a non-actiontable animation is playing, and rechecks which animation to use. This, combined with the odd fact that mVelocity is always zero in that one pickActionAnimation call, kept setting the animation back to root when the player moved.

Once I make sure all the other oddities are ironed out, I'll submit a resource.
#4
11/26/2007 (1:17 am)
This is an interesting way to get around this topic.

Good work ;)
#5
12/02/2007 (3:15 pm)
It's done. I'll post code soon.
#6
12/02/2007 (6:44 pm)
Ok, you can use the file links above.
#7
12/02/2007 (9:05 pm)
Did you tag your changes with comments?
#8
12/02/2007 (9:23 pm)
I just ran a diff against vanilla 1.5.2, doesn't look commented (with a few exceptions), but there are actually only a couple dozen changes and with winmerge they're easy to find and to see what was done to get it working.

Looks good Dan, will be useful for me in helping to figure out a sword combat game with multiple new animations, thanks.
#9
12/29/2007 (11:10 pm)
This sounds like a really good idea.
#10
01/11/2008 (5:21 pm)
How about applying to TGEA?

The routine related player sequence handling code is a bit hard coded so make it dirty to change it on script side explicitly.

Good try. ;-)
#11
01/15/2008 (10:08 am)
I think it'll apply to TGEA easily, because there are no rendering calls. I don't own TGEA so someone else will have to test this.
#12
02/29/2008 (1:00 pm)
Dan, if I have extra animations -- like melee, crouching, etc. -- how will this resource work with them?
#13
03/01/2008 (10:16 am)
Maddermadcat,
your axtra animation sequence number MUST appear to the enumerators's numbers in ActionAnimationList (player.cc) and enum (player.h .. if you use it of course), just follow the same order.
#14
03/04/2008 (10:23 am)
Only add the action animations (like crouching) to the list. I'm not sure exactly how to add melee animations, though.
#15
03/09/2008 (4:55 pm)
Another thing worries me about this resource -- how will it affect performance?
#16
03/18/2008 (2:08 pm)
Not noticeably