Game Development Community

Mounted items on Vehicle issue

by Howard Dortch · in Torque 3D Professional · 06/09/2014 (5:15 am) · 6 replies

I have a truck vehicle. Players can put things in the truck bed using %truck.mountObject(%obj,%node)
I have also tried mountImage() before you ask.
In 3rd person watching the truck as it moves, all the items jerk to keep up with the truck. Like the objects are not being moved at the same time the rover is. It worked fine in T3D pro so something changed.
Any help?

#1
06/09/2014 (6:46 am)
Howard, What object class are you using for the 'items' that are being mounted and how are they being created in script? I'm guessing that the node you're mounting to is not animated in the vehicle shape, please confirm. There is some push right now to clean up and add some consistency to object mounting. It would be nice to see this issue identified and rolled into the same ticket.
#2
06/09/2014 (8:52 am)
I have tried both with the same result

datablock StaticShapeData(GprDevice)
datablock ShapeBaseImageData(GprImage)

There are 2 mounts for players to ride (Mount0 and Mount1)
Player seems to move with the vehicle properly

The bed has 4 (Mount2 3,4,5)

Not sure what you mean by "node not animated" it was built as part of the vehicle
Thanks for the reply
#3
06/09/2014 (12:51 pm)
This is a very simple bug to duplicate. Just put
datablock StaticShapeData( BouncingSSBoulder )
{	
   shapeFile = "art/shapes/rocks/boulder.dts";
};

datablock WheeledVehicleData(CustomCheetah : CheetahCar)
{
   nameTag = 'Custom Cheetah';
};

function CustomCheetah::onAdd(%this, %obj)
{
   CheetahCar::onAdd(%this, %obj);
   %obj.unmountImage(%this.turretSlot);
   %aRock = new StaticShape(CarRock) {
      datablock = BouncingSSBoulder;
   };
   %obj.rock = %aRock;
   %aRock.car = %obj;

   %obj.mountObject(%aRock, %this.turretSlot);
}

function CustomCheetah::onRemove(%this, %obj)
{
   if( isObject(%obj.rock) )
   {
      %obj.unmountObject(%obj.rock);
      %obj.rock.delete();
   }

   CheetahCar::onRemove(%this, %obj);
}
into an executed script file, launch a level and drop in a 'custom cheetah'. The problem is caused by the client objects process order. I stepped through this and saw the process order was Vehicle, StaticShape, Player. The Vehicle isn't processing ticks because of this, it is being ticked directly by the player here and here. The line here indicates that the vehicle should be processing after the player and on the server it is. On the client, ShapeBase::setControllingObject() is being called before the object is mounted, so the ordering here actually breaks the afterObject chain on clients.
There is a one-line fix for this here. This change is also needed so objects mounted from script after the vehicle has had it's controlling object set will have their afterObject chains set correctly.

By "node not animated" I meant there's no ambient or damage animation thread playing that moves the mount node.
#4
06/10/2014 (5:29 am)
Thanks, that seems to fix the issue. I had another issue with mounting images or mounting the objects the code in the wheeledvehicle

void WheeledVehicle::prepBatchRender(SceneRenderState* state, S32 mountedImageIndex )

Tells me we mount images instead of objects and caused a crash

http://www.garagegames.com/community/forums/viewthread/137151

Any clarification on mount objects or images while we are digging into it?
Thanks again for your help here.
#5
06/10/2014 (6:53 pm)
I'd only mount an image if you need the added functionality of the image type. I only use images for weapons, but that's just preference. You can get around the lack of mountPoint detection by mounting with an offset. %obj.mountObject(%shape, %node, %offsetTransform) or lining up the shape origin with the mountPoint. If you're inclined to roll your own, you can get a good start on a very lightweight mountable object by grabbing just the TSDynamic class from this branch and adding any additional features that you need.
#6
06/13/2014 (7:03 am)
Hmmmm it seems this may be the source of a problem I mentioned here:

www.garagegames.com/community/forums/viewthread/132362

I'll test the Mount Process Order Fix(es) tonight and report back

update:

Tested this afternoon and it does fix the issue with mounted rotors/props on vehicles. Muchimas Gracias!