Game Development Community

Paul Dana's turret reource vs turretShape?

by Ronald J Nelson · in Torque 3D Professional · 05/30/2014 (11:45 pm) · 4 replies

So I noticed that Paul Dana's turret resource keeps getting ported even though there is a turretShape class.

I glanced at it and am trying to understand what the advantage is. The only big difference I saw was the turretShape class extends the Item class which extends ShapeBase whereas the turret resource extends ShapeBase directly.

Could someone enlighten me what the advantage is? Additionally, does anyone know of a good example or resource on how to use the turretShape class that you can mount a player to?

#1
05/31/2014 (8:49 am)
So looking at his resource, which is here, by the way:

http://www.garagegames.com/community/resources/view/4116

It seems his version of the turret code allows you not only to use the turret as a sentry gun(Like in stock T3D), but you can mount to it like a vehicle or an anti-aircraft gun, and you can attach it to a vehicle and have one person drive and one person fire, like a tank. I'd say it's much better than stock T3D's turret system and that we should add it if we can't already do these things natively.

Also, if there's a version for the latest MIT version of T3D, please lemme know.
#2
05/31/2014 (12:41 pm)
This should all be possible with the turretShape, which seems to be heavily based on the Paul Dana turret resource, however as usual little bits and pieces have been left out or were never tested.

Just mounting a Player to a TurretShape and controlling it should already work fine. It's just that there are no script functions to make this actually happen at any point.

Just looking at my current code it looks like I had to add two functions to the turretShape class to get proper collision with turrets (may want this for collision-based mounting to them or just placing them in the environment?):

//[HNT]
bool TurretShape::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere)
{
   return ShapeBase::buildPolyList(context, polyList,box,sphere);
}
void TurretShape::buildConvex(const Box3F& box, Convex* convex)
{
   ShapeBase::buildConvex(box, convex);
}
//[/HNT]

And make sure those functions get into turretShape.h as well.

The reason you have to do this is because the Turret inherits from Item which uses a simplified collision model. This just returns it to using the ShapeBase code.

Mounting turrets to vehicles should be no issue (just make a turretShape Datablock and mount it to a vehicle), and then you can control the turret by making it the client's control object (or the Player's I suppose).

The one issue I haven't solved is that if you're driving the vehicle directly while a turret is mounted to another slot then the turret will stutter and bounce around while you move. I believe this is because the mounted turret needs to processAfter the Vehicle? Not actually sure, but I've been fixing up a lot of Vehicle stuff lately so I'll try to take a look at that one.

If you're looking for Battlefield style tank control (drive tank and control turret) you'll need turret-as-controlobject functionality. You can get this by copying some code from Player which handles passing control events from one ShapeBase to another. I wrote a resource for this here: http://www.garagegames.com/community/resources/view/21725

I don't recommend just downloading the files because there may have been other code changes since T3D 1.2 (maybe I should update the files), but the step by step instructions should still be valid.
#3
05/31/2014 (1:18 pm)
Thanks you for all of the information guys. Henry, I will definitely be checking out your resources.
#4
05/31/2014 (9:21 pm)
Thanks, @Henry, I read that in Rick's voice.