Game Development Community

Mounted objects behaving differently in show tool and torque

by Amr Bekhit · in Torque Game Engine · 09/14/2006 (3:08 pm) · 5 replies

Hi all,

I'm having a bit of trouble with some mounted objects in Torque. I modelled a character and a sword and shield. When mounting the sword and shield on the character in Show Tool Pro, it looks and animates as it should do. So, thinking that everything is fine I placed these in game only to find that the sword and shield do not mount correctly in game.

Here is the character in Show Tool Pro:

i50.photobucket.com/albums/f337/TheHoplite/helmut1.jpg
And here it is in Torque:

i50.photobucket.com/albums/f337/TheHoplite/helmut2.jpg
I did some searches but it doesn't seem like I can add an offset on mounted objects. What could possible be wrong?

Here is the code used to place the character in game:

Character code
//Helmut Player

exec("~/data/shapes/helmut/helmut.cs");

datablock PlayerData(PlayerBody)
{
   className="HelmutPlayer";
   emap=false;
   shapeFile="~/data/shapes/helmut/helmut.dts";
   destroyedLevel=100;  //Health = 100
   disabledLevel=200;   //Disable disabling :D
   
   cameraDefaultFOV=90;
   cameraMaxDist=10;
   cameraMinDist=5;
   observeThroughObject=true;
   useEyePoint=true;
   
   renderFirstPerson=true;
   maxStepHeight=0.5;
   horizMaxSpeed=10;
   runForce=100;
   maxForwardSpeed=10;
};

function HelmutPlayer::onAdd(%this,%obj)
{
   //When the player is added, we want to mount the sword to his right hand
   //and the shield to his left
   %sword=new StaticShape(){
      datablock=Sword;
   };
   
   %shield=new StaticShape(){
      datablock=Shield;
   };
   
   //Mount the sword onto Helmut
   %obj.mountObject(%sword,0);
   %obj.mountObject(%shield,1);
   
   MissionCleanup.add(%sword);
   MissionCleanup.add(%shield);
}

The sword
//sword.cs

datablock StaticShapeData(Sword)
{
   shapeFile="./sword.dts";
   isInvincible=true;
   
};

and the shield
//shield.cs

datablock StaticShapeData(Shield)
{
   shapeFile="./shield.dts";
};

Not only that, but the eye and cam nodes don't seem to be working in Torque - when in 1st person, the camera is inside the character model and in 3rd person I think that's it's a fair distance directly above the model.

--Amr

#1
09/14/2006 (3:28 pm)
A wild guess, try making the mounting objects Items instead of StaticShapes[or perhaps use ShapeBaseData instead]...? Appears as though they're mounting to their Origin, not their mountPoint. The player's Nodes seem to be located correctly. I don't understand why they're not weapons or items...eh.
#2
09/14/2006 (4:29 pm)
Thanks for your reply.

Tried making them Items and using ItemData, but they just don't get rendered.

You know what boggles me? Isn't the Show Tool Pro Torque? If it works in the Show Tool, it should surely work in Torque. Is there something in my code wrong that's causing this?

--Amr
#3
09/14/2006 (4:36 pm)
If they're turned into items, the hooks into the inventory.cs need to be there, I think? The player has to have a maxInv count for the stock code...Yes; if it mounted correctly in STP, this must be in your scripting of the objects and the mounting...my opinion. I've really only mounted ShapeBaseImages instead of Objects, so I'm not entirely certain.
#4
09/15/2006 (7:07 am)
Well I've managed to solve the problem for the time being - It seems that when Torque mounts StaticShapes onto other objects, it uses the shape's bounding box origin (or maybe this is an artifact of the Maya exporter). So, in my model file I changed the position of the bounding box origin to match that of the mount point and it works fine.

Is this a bug in Torque then?

--Amr
#5
09/15/2006 (8:45 am)
Default StaticShapes ignores the position of the mountPoint node. Player has the relevant code, just rip it out.