Game Development Community

Turret

by J Brown · in Torque Game Engine · 10/30/2001 (3:55 am) · 8 replies

For the past few days I've been fooling around with the bot code. I was successful in getting the bot to detect my presence and pivot around while aiming his weapon at me.

Now I'm interested in making a turret. I was wondering if anyone has done this yet, or if someone has an idea where to start?

My first thought was to start by taking the Player object (and AIConnection perhaps?) and modifying the shapefile and some of the code to act as a turret instead. Basically that the 'body' of the player would become the body of the turret, and that the head or weapon could become the 'barrel' of the turret.

I modified my AIConnection to automatically track a target, so maybe I could use this for the turret aiming code?

But, that was just my initial thoughts and I'm not sure if I'm even close on how to approach this problem. If anyone can point me in the right direction, or at least tell me if I'm thinking along the right lines or not, I'd sure appreciate it.

Thanks.

#1
10/30/2001 (4:32 am)
Yeah, something derived from AICOnnection seems the best bet to me. It might be better to make a base class of AI object that can handle general events via virtual functions and then make specialised cases for these for ai opponents/turrets/etc.

Basically, to my mind, its better to have an AIObject class that is created and connected to an AIConnection object in order to then reuse code that AI needs to use in general (area of interest, movement planning or whatever).

Basically, play around with it :))

Phil.
#2
10/30/2001 (12:08 pm)
Thanks Phil, for replying.

Yes, I do plan make Turret a separate class for the turret itself. But I probably will use AIConnection (or a new subclass) to do the "AI" controlling of the turret.

I got this working to some extent already, using the T2 turret base for now, until I get something else from our modeler.

Only problem I can see right now is, controlling the base's "head" itself (thing the barrel mounts into). It doesnt seem to be a separate object, so all I can guess is that T2 used animations to rotate this thing???
#3
11/18/2001 (1:49 am)
Right, no reply... go figure

Anyway, for anyone who may be reading this and wondering, the turret barrel in t2 is moved via animation sequences, just like the player's head.

So basically I got the turret working by copying the Player class to obtain a new Turret class, changing a bunch of strings to "Turret", removing some player-specific code, and changing the head threads to activate the turret sequences instead.

Think I also had to turn freelook on all the time and change the min/max look angles.

Hope this helps anyone trying to do turrets.
#4
11/18/2001 (8:52 am)
I'm not trying to do turrets but thanks for posting the solution. A lot of people lately seem to be announcing problems, eventually getting the answer, and not posting the final solutions. That just means the next person has to go thru asking all the same questions. This just makes the forums larger and more cumbersome to navigate. I think we need a few more "Code snippet" donations from the group. It might also be useful to add versions to the current ones. Some only work under V12 or won't work on later versions without substantial modification.
#5
12/07/2001 (4:08 pm)
Tutorials, guys, tutorials.... Spend an hour tomorrow tell us how :)

I know guys- not enough of those in a day.

Good work.

Scott
#6
01/08/2002 (11:25 pm)
eventualy i wouldlike to know more on turrets for torque
[edit]wow old post(link removed)[/edit]
#7
01/10/2002 (2:33 am)
Hmm, I'm not sure about using the player class as a base. I'll have a go at doing it myself (turrets) and see if I can do it differently.

If you look at the turret.cs code, you'll notice that they depend on sensor's. Sensors as far as I can tell are just bounding volumes of some form (bounding sphere's) that are used as triggers for AI controlled objects (turrets etc).

Sensors are also used in some ship weapons arent they?

Basically, I'm going to try and put back some of the functionality that T2 for sensors and see if I can figure out how to implement the turrets from there.

Phil.
#8
09/08/2002 (2:53 pm)
anyone got anything on this yet?