Game Development Community

Player spawned objects

by Carl A Harris · in Torque 3D Professional · 12/31/2010 (7:58 pm) · 3 replies

Are there any suggestions on how to make a player created/spawned object?

Like a turret or a simple block to take cover behind. Even pick up and move.

Or perhaps better key words to use, to locate these types of resources.

#1
12/31/2010 (10:57 pm)
You need a shape/model/object of course, a datablock, location (transform), and the 'new' command for whatever class of object (StaticShape, Item, RigidShape, etc) you're wanting to instantiate - a few examples exist in stock code (weapon/ammo/health drop for example).
#2
12/31/2010 (11:35 pm)
A wonderful learning example of player initiated object interaction is found in the weapon.cs script file.

Take notice of the WeaponImage::onFire function, this function spawn a projectileType object, but could easily be changed to spawn any other object type.
Try this;
%p =    new Item()
   {
      dataBlock = "HealthKitSmall";
      position = %obj.getMuzzlePoint(%slot);
   };
in place of;
%p = new (%this.projectileType)()
   {
      dataBlock = %this.projectile;
      initialVelocity = %muzzleVelocity;
      initialPosition = %obj.getMuzzlePoint(%slot);
      sourceObject = %obj;
      sourceSlot = %slot;
      client = %obj.client;
   };



#3
01/01/2011 (4:52 am)
Thanks guys, I'll try that. :)