Game Development Community

Mount and use a weapon as an object and not as an image (ShapeBaseImageData)

by Isidoros · in Torque Game Engine · 11/22/2009 (3:41 pm) · 5 replies

I am trying to script an FPS application

I want my weapon not to be static, in first person POV, but follow the motion of my avatar (up and down when avatar is moving/running). So I have decided to mount the weapon as object on the player
%player.mountObject(%mountedWeapon,$weaponNode);
where %mountedWeapon is a StaticShape object,
and NOT as image
%player.mountImage(WeaponImage,$weaponSlot);

The "party" now starts! Lets say that I want to get all the advantages of the ShapeBaseImageData (state machines for example). So I was thinking to mount an image at the muzzle of the gun (my weapon)
datablock ShapeBaseImageData(WeaponImage)
{
  // Basic Item properties
  shapeFile = "~/data/items/hook.dts";
  emap = true;

  // Specify mount point & offset for 3rd person, and eye offset
  //for first person rendering.
  mountPoint = 0;
  offset="0 0 0";
  eyeOffset = "0 0 0";
...
...
// Initial start up state
   stateName[0]                     = "Preactivate";
   stateTransitionOnLoaded[0]       = "Activate";
   stateTransitionOnNoAmmo[0]       = "NoAmmo";

   // Activating the gun.  Called when the weapon is first
   // mounted and there is ammo.
   stateName[1]                     = "Activate";
   stateTransitionOnTimeout[1]
...
...
};

where the dts file will be a simple box, very small in order to be hidden from the weapon model.

What do you think about applying this idea? If I want my weapon to follow player's movement can I script it differently even without the use of "images" object?

Finally if it is ok to implement the above then how will I "activate" the gun? Of-course in this case I cannot use $mvTriggerCount0 or $mvTriggerCount1.

#1
11/22/2009 (3:50 pm)
Quote:I want my weapon not to be static, in first person POV, but follow the motion of my avatar (up and down when avatar is moving/running).
I'll take a look around to see how I used weapon mounting but I am already using shapebaseimages that are acting exactly like you have said... no special coding or objects needed.

Edit: heres the code block I think will do what you need:
eyeOffset = "0 0 0";
   eyeRotation = "1 0 0 0";
   useEyeOffset = false;
   firstPerson = true;
Mainly useEyeoffset = false I believe, hope that helps.
#2
11/22/2009 (5:06 pm)
Also take a look at this.
#3
11/22/2009 (5:19 pm)
Thnks CSMP. I checked it and it works.

Bun now lets reveal my little secret. When I mounted the image I could not see my gun in first person POV. To be more specific I cannot see the gun when Iam looking straight only when I look down! This is why I want to mount the gun as object and not as image. I believe the problems are the way I modeled my avatar and the eye node but I didnt manage to solve them.

Screenshots (mount gun as image): 3rd view, 1st view look straight, 1st view look down

Update:Ooops..sorry Daniel..I noticed your comment when I had already made this "answer"post. I dont feel ready to hack the engine yet. When I finish with scripting Iam going to "play" with the engine's code.
#4
11/22/2009 (6:21 pm)
Yeah, I noticed that same problem when I first tried also, I used the SniperLook ArmThread in the A.C.K.(B.A.G. Advanced Character Kit) as my standard weapon ArmThread then used the source for the SniperLook and modified it further for a "ironsights" ArmThread... (as the smglook and mglook were similiar and very low on the screen as well)

Even though it is not "true" ironsights it has helped me bring the weapon into the view of the FPS cam and with the inclusion of the Realistic FPS View Resource (Daniel's link) between the movement of the weapon in the hands and the head "bobbing" it looks awesome.
#5
11/22/2009 (7:25 pm)
Isidoros - that's just an animation problem you'll have to deal with if you want to do weapons this way. If you held a gun by your hip like that in real life, you'd barely be able to see it either (and that's with increased human FOV). Most FPSs attach the weapon to your HUD in a position that probably equates having the gun at your shoulder, not hip, so your animations will need to reflect that.

Also, I recommend getting into source code as soon as possible - but I completely understand that it's pretty daunting ;).