Game Development Community

Mounting ShapeBase to FlyingVehicle

by Eric den Boer · in Torque Game Engine Advanced · 03/11/2009 (7:22 am) · 7 replies

Dear all,

When trying to mount a missile DTS shape, it just won't work. The onMount() event handler does get called. This is what we're trying to do:

This is the ShapeBase code that makes up the projectile.
datablock ShapeBaseData(dbBaseProjectile)
{
   category       = "Projectiles";
   className      = Missile;
   
   shapeFile      = "~/data/shapes/projectiles/omgmissile.dts";
   scale          = "1 1 1";
   
   aiAvoidThis    = true;
};

// MOUNTING CODE
function Aircraft::onAdd(%this, %obj)
{  
	%obj.setEnergyLevel(%this.MaxEnergy);
	%obj.setRechargeRate(%this.rechargeRate);
	%obj.setRepairRate(%this.repairRate);
	
	%missile0 = new ShapeBase()
	{
	   dataBlock = dbBaseProjectile;
	};
	
	// Mount missile0 on player
	%obj.mountObject(%missile0, 0);
}

I checked the models. The missile model has a joint called "mountPoint" and the aircraft has a joint called "mount0" and "mount1". The Missile::onMount() gets called, however .. we can't see anything.

#1
03/11/2009 (8:43 am)
I think mountImage is what you want instead of mountobject.
Basically the difference is a image is passive(mostly use just to render an image) and an object is active(can have logic code to interact with other objects).

I think this thread talks about what you need.
#2
03/11/2009 (11:56 am)
But, we need to attach the model of a missile to an airplane... how can we use an image for that? :(
#3
03/11/2009 (12:44 pm)
The mountImage method is the same way in which weapons are mounted on a player, mounting flags or other "accessories" to a player model, it's also the general way of mounting turrets to a vehicle -- simple really.
#4
03/11/2009 (1:47 pm)
So DTS models can be used for "images" ? Or have I not understood the concept of images in this particular case? :)
#5
03/11/2009 (2:12 pm)
Images in this case are a bit of a misnomer.
A shapebaseimage in this case is a DTS object and can literally be the same DTS file you use for the shapebase object.

Just take a look at how the starter.fps example game uses the crossbow image(DTS) for mounting to the player and how it is also an item(which is derived from the shapebase class) to be displayed in the mission.

Open up the crossbow.cs file and read it's comments on the difference between the two.

This image versus object had me confused at first too.
#6
03/12/2009 (12:46 am)
Alrighty, thank you! It's good to know that I'm making the same mistakes as the gurus, means I'm on the right track :)

The book does explain stuff about images, but I thought it was used for something as a sprite.
#7
03/12/2009 (6:41 am)
It worked :D Weird, but works. Thank you so much for your help!