Game Development Community

Adding different arm positions for weapons help

by Tim Heldna · in Torque Game Engine · 10/07/2004 (4:12 pm) · 7 replies

I'm in need more help on trying to get a different arm position when swaping
different guns. Im pretty new to scripting so it would be great if a little
more detail can be used.


Ive gone through all the scripts, turorials and this is one thing that I can't find
anything on!

#1
10/08/2004 (1:35 am)
You need a different animation pose for each weapon, and then in script you call which one for which weapon. The poses are each 3 frames long, weapon high, weapon low, weapon middle. Current naming convention is look_de.dsq (default look).
#2
10/08/2004 (2:21 am)
You have to use the setArmThread function, passing the name of the sequence that contains the arm animation
ie:
in the function Weapon::onUse that is in the weapon.cs file

Weapon::onUse(%data, %obj)
{
...

%obj.setArmThread(%data.image.armThread);

...
}

where armThread is a script variable defined in the image of the weapon which contains the sequence name
#3
10/08/2004 (2:27 am)
For a custom solution you may want to look in the player class at how the recoilSequences are used (search 'recoilSequence'). However, as this comment suggests, its only clientside.
#4
10/09/2004 (4:19 pm)
I do it in the onMount function, and you might want to throw an if statement in there.

function WeaponImage::onMount(%this,%obj,%slot)
{
   // Images assume a false ammo state on load.  We need to
   // set the state according to the current inventory.
   if (%obj.getInventory(%this.ammo))
      %obj.setImageAmmo(%slot,true);
      
   if (%this.armthread $= "")
      %obj.setArmThread(look);
   else
      %obj.setArmThread(%this.armThread);
}
#5
10/10/2004 (1:23 am)
I don't do it in the onMount function because when the player is spawned I mount several weapons on it but I use only one at a time :)
But if you use the standard torque, either your solution works well, because you can use only the weapon that you mount
#6
10/10/2004 (1:53 pm)
Ok, so if i enter the armThread code into the weapon.cs file
what do I need to enter into the the e.g crossbow.cs file to
call on my second armThread animation?
Thanks
#7
01/04/2007 (4:10 pm)
My game was crashing whenever i called setArmThread(....)

i figured out why -- the mArmAnimation.thread variable was NULL in player.cc ... apparently this is initialized when you have a look animation ONLY..... so you might be able to fix this by loading up a look somehow.

i fixed this by modding the C++ by adding this code:

if (!mArmAnimation.thread)  
	   mArmAnimation.thread = mShapeInstance->addThread();

right at the beginning of Player::setArmThread

i post this here to save anyone interested in armThreads the heinous debugging i had to get into.