Adding New Player Animations?
by Donnie Bugden · in Torque Game Engine · 04/05/2005 (3:09 pm) · 13 replies
Can anyone tell me how to add new animations for the player character? I need to be able to add new custom animations and bind them to new keys. Can this be done through scripting? Do I have to modify player.cc to accomplish this?
I have a week to get an insane amount of work done. That is why I am posting this. If anyone knows where I can find sample scripts for this. That would be so awesome.
Thanks,
Donnie
I have a week to get an insane amount of work done. That is why I am posting this. If anyone knows where I can find sample scripts for this. That would be so awesome.
Thanks,
Donnie
About the author
#2
Thank you for your informative post. I am adding more animations like the wave and salute. This is exactly what I need to do. This is a great starting point. I am close to getting out of Maya and back to doing some coding this weekend. I will let you know how it turns out.
Cheers,
Donnie
04/05/2005 (7:48 pm)
Hey Martin,Thank you for your informative post. I am adding more animations like the wave and salute. This is exactly what I need to do. This is a great starting point. I am close to getting out of Maya and back to doing some coding this weekend. I will let you know how it turns out.
Cheers,
Donnie
#3
Would be used like this...
04/06/2005 (9:09 am)
Sure they can be loopedfunction Player::Salute(%this,%x){
for(%counter = 0; %counter <=%x; %counter++){
%this.setActionThread("Salute");
}
}Would be used like this...
%player.salute(10);
#4
04/06/2005 (10:44 am)
Just to be pedantic, that's not "looping" in the terminology of animations, but "repeating a non-cyclic animation 10 times". The effect is the same visually (kind of), but it can make a world of difference in understanding what is going on internally.
#5
(This was using blender)
04/06/2005 (11:03 am)
Oh ok, I see what you mean now... On my fish character I have an animation called swim that is played all the time, all I did was create the animation and set the cyclic button to TRUE in the exporter.(This was using blender)
#6
04/06/2005 (9:26 pm)
Thanks everyone for the posts. I am starting to get out of Maya, and back to doing some coding. This is the starting point I needed. You guys are great! Cheers.
#7
http://www.garagegames.com/docs/torque/general/ch06s04.php#id2574597
thanks everyone for the posts and helping me work this out.
04/07/2005 (2:13 pm)
Cool. it is working for me, but here is a quick heads up. you must delete client/config.cs. to get it to work. here is some info from the docs:http://www.garagegames.com/docs/torque/general/ch06s04.php#id2574597
thanks everyone for the posts and helping me work this out.
#8
Would be you able to use newly created animations for melee battle here?
...how would you make the blade of the weapon deal damage as well?
Thanks!
04/23/2005 (5:36 am)
Quick question on this:Would be you able to use newly created animations for melee battle here?
...how would you make the blade of the weapon deal damage as well?
Thanks!
#9
Here's a resource that has Server Side Melee which has new animations for the melee attack and damage for the weapon. This should help you.
Server Side Melee, I have tested this on TGE 1.3.
04/23/2005 (6:33 am)
@FrancisHere's a resource that has Server Side Melee which has new animations for the melee attack and damage for the weapon. This should help you.
Server Side Melee, I have tested this on TGE 1.3.
#10
04/23/2005 (6:50 am)
Thanks! I appreciate that help! :)
#11
05/31/2005 (3:02 pm)
This stuff is right up my ally! Just what I was looking for! I'll try it out & give some feedback of my own...
#12
I have a new animation,i call it "aim" it is sequence no 9 in the soldier.cs file.
I want to be able to "call" it up utilizing the right mouse button.
in a nutshell, right click to aim-left click to fire
this would be a cool feature,and i need help to implement this for the soldier pack.
can anyone help?
06/11/2007 (8:20 am)
Sorry to necro this thread,i havent been able to find any info of this subject.I have a new animation,i call it "aim" it is sequence no 9 in the soldier.cs file.
I want to be able to "call" it up utilizing the right mouse button.
in a nutshell, right click to aim-left click to fire
this would be a cool feature,and i need help to implement this for the soldier pack.
can anyone help?
#13
You could just make a function to set the melee animation thread and use the InitContainerRadiusSearch or something to search around the gun's transform for players other than the holder of the gun, and apply a force vector and damage to the player(s). See below pseudocode:
07/26/2007 (4:52 pm)
Quote:
Quick question on this:
Would be you able to use newly created animations for melee battle here?
...how would you make the blade of the weapon deal damage as well?
Thanks!
You could just make a function to set the melee animation thread and use the InitContainerRadiusSearch or something to search around the gun's transform for players other than the holder of the gun, and apply a force vector and damage to the player(s). See below pseudocode:
MaleAvatar::doMelee(%this)
{
%weapon = %this.GetWeapon();
%this.SetActionThread("Melee");
%players = InitContainerRadiusSearch(%weapon.GetTransform(), %weapon.meleeRadius, $TypeMasksExceptPlayers, %this); // (Or search 'radius' around the weapon for other players only)
%players.ApplyDamage(%weapon.meleeDamage);
%players.ApplyVector(GetVectorBetween(%weapon, %players));
}
// Remember, this is pseudocode, it doesn't really work as is.
Torque 3D Owner Martin "Founder" Hoover
in starter.fps/data/shapes/player you will find a file named player.cs, this contains the TSShapeConstructor which defines the animations for the player.dts shape whenever it is instantiated.
It lists out the sequences in an array like so:
sequence0 = "./player_root.dsq root";
Of course "./player_root.dsq" is the file containing the animation data, and "root" is the sequence name for that animation.
It appears that the total number of action animations is 68, so you should be able to add another 39 animations to the default player from starter.fps.
So to add another simply increase the number for the sequence, enter the file name for the animation, then give the animation a name that is unique amonge the sequences for this dts.
Then to trigger the animation you use the following call:
PlayerObjectID.setActionThread("sequence name", bool [hold at end], bool [first person view]);
Use the name you gave the sequence to trigger the one you want played. I believe that the hold at end boolean will make the animation pause at the end frame and stay at that frame until the player starts moving from his location. I'm not really sure of the effect of the boolean for first person view, as I've never really messed with it.
So you might end up with a call looking like so:
%player.setActionThread("salute", true); (the player should hold the ending salute pose) or..
%player.setActionThread("victory_dance"); (since no bools were given they would be assumed false, thus at the end of the animation, the player would return to the "root" animation)
I do not think these can be looped without changing the source code, so they'll only play once, but they can be triggered by a keypress.
For an example of how to implement the anim via a keypress look in client/scripts/default.binds.cs and look for:
moveMap.bindCmd(keyboard, "ctrl s", "commandToServer('playCel',\"salute\");", "");
line 212.