Game Development Community

Adding meshes to scene

by Martin Banks · in Torque 3D Professional · 08/17/2009 (1:38 pm) · 9 replies

When I add a mesh to the scene from the library it is automatically added with its source class designated as TSStatic. How can I change this source class, or add the model in a way that its source class is for instance, player?

#1
08/17/2009 (2:08 pm)
Create a datablock for the object type you want (Player, StaticShape, etc) and write a name to its "category" field. The name you write in "category" will show up as a folder in the "Scripted" tab in the Library, with objects using the same "category" grouped together.
#2
08/17/2009 (2:29 pm)
Meshes are just that: meshes. That's why they're added as TSSTatics, a very lightweight object class that doesn't have much interaction -- great for props/scenery.

Do as Manoel outlined for scripted objects, if you want more out of your object.
#3
08/17/2009 (4:05 pm)
I created the datablock, and now see my category present in the library. However the datablock is listed, which does not bring in my character's mesh. So, having created the datablock, how then do I get the character into the scene?
#4
08/17/2009 (4:50 pm)
Let's see your datablock.
#5
08/17/2009 (5:00 pm)
also make sure your new script is being executed...i think it needs to be added under game.cs ie exec yourscript.cs under similar lines.....but my memory is a little sketchy at the moment so i may be wrong on the location
#6
08/17/2009 (5:08 pm)
datablock PlayerData(MySoldierData : DefaultPlayerData)
{
   renderFirstPerson = true;
   pickupRadius = "1";
   DecalData = "PlayerFootprint";
   footPuffEmitter = "LiftoffDustEmitter";
   dustEmitter = "LiftoffDustEmitter";
   FootSoftSound = "FootLightSoftSound";
   FootHardSound = "FootLightHardSound";
   FootMetalSound = "FootLightMetalSound";
   FootSnowSound = "FootLightSnowSound";
   FootShallowSound = "FootLightWadingSound";
   FootWadingSound = "FootLightWadingSound";
   FootUnderwaterSound = "FootLightUnderwaterSound";
   FootBubblesSound = "FootLightUnderwaterSound";
   movingBubblesSound = "FootLightWadingSound";
   splashEmitter[0] = "PlayerSplashMistEmitter";
   splashEmitter[2] = "PlayerSplashEmitter";
   shapeFile = "art/shapes/players/bagdadsoldier/low_poly_character.dae";
   Explosion = "RocketExplosion";
   underwaterExplosion = "RocketSubExplosion1";
   Debris = "PlayerDebris";
   category = "MyGuys";
};
#7
08/17/2009 (5:32 pm)
That looks right (I would question the 'explosion' fields), but it isn't going to do anything on it's own. How are you intending on using this? As a player or as a bot? I believe you can add a 'Create' method for player shapes to the editor, but by default there isn't one because player/AI instantiation is handled differently from other objects, and if you did so it would only stand there without doing anything.

If you want the player to spawn as "MySoldierData" you would have to pass that datablock name into the spawn marker you use.

If you're intending this to be a bot/AI construct of some sort you would have to change the aiPlayer methods to use your new datablock. And to properly spawn a bot via the default AIManager you would have to set up a path and series of path markers for it to use.
#8
08/17/2009 (5:46 pm)
Thanks Michael,

I want to use this character initially as a player, then later as a bot.

I have animations that I can add as sequences, and have done so using the object editor successfully, but only as a TSStatic object. I want to control the player like the default players are setup (arrow keys to translate and mouse for direction). Additionally, I want my character to be collidable.
#9
08/17/2009 (5:57 pm)
In your level/mission file (through the editor) find the spawnpoint/spawnmarker and make it's spawnDatablock field read "MySoldierData". That way when you spawn in-game you should be your new player object. If all is correct then your new player will control just like any other.

Players have a bounding box for collision, so you may have to tweak the setting for it in order to conform more to your player's mesh size. The DefaultPlayerData uses a XYZ size of "1.2 1.2 2.3". Just add the boundsBox field to your datablock with your settings to override the default. To see the bounding box you will have to be inside the editor and have your player selected. The box will then be indicated as a white? (I'm colorblind) box/outline around your player.