Game Development Community

%player.mountImage question

by Grey9999 · in Torque 3D Beginner · 11/13/2012 (9:52 am) · 5 replies

I noticed %player.mountImage(ImageName, number) only works if the number is 0,1,2 or 3. But you can have more than one image assigned to each number, and be mounted to different nodes. (in my case I have My glock handgun and sunglasses for my character both assigned to slot 0 with mount image but they are mounted to mountnodes6 and 3 on my model and seem to work fine). So what is the point of the slot # that you assign in the mountImage command?

#1
11/13/2012 (10:07 am)
nevermind I added a third mounted shapebaseimagedata , a holster, and realized it is not this simple. It seems I can mount 2 objects to slot 1 but the third has to go to 2...Looks like I don't have this slot thing figured out yet. And having 2 in slot 0 quit working.
#2
11/13/2012 (8:08 pm)
The weapon mounting system is a bit strange to use at first.

On the player model there should be nodes called mount0, mount1, mount2...mount10.

When you use:
%obj.mountImage(LurkerImage, 0);
this is not telling the weapon where to mount. The 0 has nothing to do with the node called mount0 on the player.
using:
%obj.mountImage(LurkerImage, 1);
will mount the weapon is the exact same position.

The number that you are putting in the mountImage function is the slot number, not the mount number. The slot number is used to figure out when you want to do something with this weapon, not where the weapon is.

Right now I think there is a limit of 4 slots on a player so 0,1,2,3.

Again this has nothing to do with the mount0, mount1, etc on the model.

The datablock for the weaponImage is where you can change where this weapon is positioned.

datablock ShapeBaseImageData(LurkerWeaponImage)
has a line
mountPoint = 0;

This means the LurkerWeaponImage is always positioned at mount0. If you want to put a weapon at a different position you need to change the mountPoint in the dataBlock.
#3
11/13/2012 (10:24 pm)
Right I understand all of this. I'm just trying to figure out what the slots actually mean.
#4
11/14/2012 (1:02 am)
The slots are usually used to fire the gun.
in default.bind.cs you have:

function mouseFire(%val)
{
   $mvTriggerCount0++;
}

function altTrigger(%val)
{
   $mvTriggerCount1++;
}

moveMap.bind( mouse, button0, mouseFire );
moveMap.bind( mouse, button1, altTrigger );

so when you press the left mouse button (button0) it runs the function mouseFire.

This then increments $mvTriggerCount0 which is a special variable that toggles trigger 0 to be either on or off.
button1, or the right mouse button increments $mvTriggerCount1 that turns trigger 1 on or off.

Thing of the slots and the triggers to be the same thing. Trigger 0 is somethign mounted in slot 0, trigger 3 is something mounted in slot 3.

So if you mount a weapon with:
%obj.mountImage(gunImage,0);
this will fire with $mvTriggerCount0.
With an AIPlayer you can make them shoot their weaponin slot 0 with:
%aiplayer.setImageTrigger(0, true);
to make them stop shooting slot 0 use:
%aiplayer.setImageTrigger(0, false);


$mvTriggerCount2 and $mvTriggerCount3 toggle the 3rd and 4th triggers, but these triggers are also used to jump and crouch so you usually don't want to mount a weapon in slot 2 or 4.

$mvTriggerCount5 toggles sprinting, but I think you have a limit of 4 weapon slots 0,1,2 and 3 so $mvTriggerCount5 wount shoot any weapons, nomatter how you mount them.

To give a weapon ammo the code is:
%obj.setImageAmo(0,true);
That will turn ammo on for the weapon in slot 0;
#5
11/14/2012 (3:31 am)
Very informative, thanks a lot. I guess you are limited to 4 weapons at a time then, but it seems the slots can be shared with non weapon shapebasedataimages though.