Game Development Community

Mounting Flashlight Objects

by JohnT · in Torque Game Engine · 04/18/2006 (11:19 am) · 2 replies

I'm having difficulty loading a flashlight object into the players hand(don't want to use Images since I am going to attach a light to the flashlight). The code I am using is the following and I have placed this in the game.cs in the createPlayer method. In debug everything looks like it succeeded, but the flashlight just does not show.

I'm sure I'm doing something really stupid here. Hope someone can tell me what I am doing wrong.
thanks, John


//-----------------------------------------------------------------------------
datablock ItemData(Flashlight)
{
category = "Accessories";
className = "Weapon";
shapeFile = "~/data/shapes/flashlight/flashlight.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
emap = true;
pickUpName = "a flashlight";
};

// Inside createPlayer() ...
// %player.setInventory(Crossbow,1);
// %player.setInventory(CrossbowAmmo,10);
// %player.mountImage(CrossbowImage,0);

%myFlashlight= new ItemData() {
dataBlock = Flashlight;
};

%player.mountObject(%myFlashlight, 0);

#1
04/18/2006 (11:33 am)
John,

You have a "maxInv[Flashlight] = 1;" in your player.cs, right? I believe if you give it a classname ="Weapon;", that hooks it into the inventory system, therefore it has to have a maxInv in the player.cs. You probably need to include it also in your inventory.cs as one of the "function ShapeBase::cycleWeapon"... that would be if you haven't already done all this, and if that's the case I'm clueless.
(But what's new!).

- Alan
Really Really Good Things Studio
#2
04/18/2006 (11:49 am)
Forgot to mention that, but yes I have done both of those things and even tried this on a fresh install of TGE without the Weapon Cycling Resource included. Still, no luck.

Thanks for suggesting that though.