Game Development Community

MountObject

by Daniel Buckmaster · in Torque Game Engine · 04/08/2007 (7:09 pm) · 14 replies

The mountObject function doesn't seem to be working on my version of TGE. It's a clean download of TGE 1.5. I go into the TLK demo mission in starter.fps and unmount the player's crossbow using player.unMountObject(0); in the console (I gave my player a name). Then I create a static shape (a health patch), and call it 'health'. In the console: player.mountObject(health,0); This seems to do nothing. If I echo that statement, it returns a 1, but the health kit does not mount to the player.
Anything I'm dong wrong?

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
04/08/2007 (7:11 pm)
You can only mount images, not static shapes.
#2
04/09/2007 (10:21 am)
Shapes can be mounted. Although I've read that static shapes dont mount using a mountNode. Make sure you are calling the correct object. Try using its' ID number instead of it's name.
#3
04/09/2007 (1:20 pm)
That's strange, because ideally you should have no problem.

How about trying to call player.unMountImage(0) first instead of unMountObject, because the crossbow is a StaticShapeImage and not a StaticShape.

--Amr
#4
04/18/2007 (10:38 pm)
Quote:Edit: I misunderstood. I see you're trying to mount the health like a weapon. I thought you wanted to mount the health to another object.
Either way - I just want the thing attached to the player!

I've tried it again in my own project, where no images are mounted. All my method calls are working, but nohing is happening.
#5
04/19/2007 (1:22 am)
You can not mount StaticShapes to other objects. Does not the name suggest that? The object is *static*. There is no code in StaticShape to handle the mounting. You have to add this yourself.
#6
04/19/2007 (2:02 am)
I already tried telling 'em that.
#8
04/23/2007 (9:39 am)
Quote:You can only mount images, not static shapes.
Quote:You can not mount StaticShapes to other objects. Does not the name suggest that? The object is *static*. There is no code in StaticShape to handle the mounting. You have to add this yourself.
I could have sworn that I *have* mounted StaticShape objects in the past. The whole idea of what I'm trying to do is NOT use the image system.

I tried using an ItemData item, and player.mountObject(item,0) returns 1 but nothing happens.
#9
04/23/2007 (10:46 am)
You can definately mount StaticShapes on other StaticShapes and Players, and you can move the shape/player around and the mounted objects will follow it as expected. Ive just gone and done this now.

As for ItemData, it seems that you cannot mount them onto other objects.

Here's a suggestion for your problem: for each item, you could have a corresponding StaticShape object which is what you mount when the player collides with the item.

datablock ItemData(GunItem)
{
    .
    .
    .
    shapeDatablock=GunShape;
};

datablock StaticShapeData(GunShape)
{
    .
    .
    .
};

In your onCollision function, when the player collides with the item, delete the item or hide it or whatever, then create a new StaticShape using shapeDatablock and mount that onto your player.

--Amr
#10
04/23/2007 (11:05 am)
Quote:You can definately mount StaticShapes on other StaticShapes and Players, and you can move the shape/player around and the mounted objects will follow it as expected. Ive just gone and done this now.
Could you share how you did that?

Quote:Here's a suggestion for your problem: for each item, you could have a corresponding StaticShape object which is what you mount when the player collides with the item.
...code...
In your onCollision function, when the player collides with the item, delete the item or hide it or whatever, then create a new StaticShape using shapeDatablock and mount that onto your player.
That's exactly why I'm not using ShapeBaseImage objects. I want the world to be more of a simulation - when you collide with a gun, you take that gun, not just a gun. Thanks for the idea, though.
#11
04/23/2007 (11:41 am)
Here's my code;

datablock StaticShapeData(ArrowData)
{
   category="Items";
   shapeFile="~/data/shapes/3dtorquelogo/arrow.dts";
};

datablock StaticShapeData(baseCubeData)
{
   category="Items";
   shapeFile="~/data/shapes/3dtorquelogo/baseCube.dts";
};

function baseCubeData::onAdd(%this,%obj)
{
   //Create four arrows and mount them on
   for (%i=0;%i<4;%i++)
   {
      %arrow=new StaticShape()
      {
         datablock=ArrowData;
      };
      MissionCleanup.add(%arrow);
      %obj.mountObject(%arrow,%i);
   }
}

Add a baseCube to the level and it will automatically spawn 4 StaticShape arrows and mount them on to it. You can move, rotate and scale the baseCube and the arrows will follow it accordingly.

If you email me (check my profile), I can send you the DTS shapes I used.

Quote:That's exactly why I'm not using ShapeBaseImage objects. I want the world to be more of a simulation - when you collide with a gun, you take that gun, not just a gun. Thanks for the idea, though.

Hmm I see. If you're determined to go that way, then I think you'll need to modify Item in the source to allow mounting.

--Amr
#12
04/23/2007 (12:01 pm)
Amr, you are partly correct. You can mount a StaticShape onto another StaticShape, but they will not be using the mountpoint. If this has changed (I am using older revisions) then by all means correct me.
#13
04/23/2007 (12:07 pm)
That's right Stefan - it uses the centre of the bounding box instead. I've found that in Maya, you can move the pivot point of the bounding box to your desired locaton and the object will be mounted correctly.

--Amr
#14
04/23/2007 (12:20 pm)
Huh, then that may be the modification I need - to make mounted StaticShapes use mount nodes. I'll need to mount stuff on both hands, and possibly belts and similar. Getting Items to use them would be really useful, too. I'll have a look at that resource Peter posted above, which looks like pretty much what I want. If it doesn't have the functionality I want, then I'll have a go at modding the source. I need experience in that area...