Game Development Community

Turret question

by David Tan · in Torque Game Engine · 09/30/2004 (12:25 am) · 47 replies

I learning from the turret resource:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345

I can mount the turret to a Vehicle,but I can not control turret with mouse.
What I wanted is:
a)control vehicle with keyboard.
b)control the turret with mouse,rotate around.
c)In 1st person view,looking where the turret is aiming.

Could somebody help me? Thanks.
Page «Previous 1 2 3 Last »
#1
09/30/2004 (4:13 am)
You need to hack up your vehicle to send the move structure to the mounted turret.

From there its easy
#2
09/30/2004 (5:06 am)
Thomas,thanks for your reply,could you give me more detail?
#3
09/30/2004 (6:43 am)
Only 1 object can be control object, meaning all movements are sent to that only. I Think the method is called updateMove(Event move) or similar

The move structure contains all the moves for the last tick - mouse and keyboard.

By calling the mounted turret updateMove with the same move, you can get the behaviour that you want.

I think thats the info you need to know to get this running - the rest is a learning experience for you.
#4
10/01/2004 (9:52 pm)
Make te turret the vehicle's mControlObject, and implement that feature as it is done in the player class.
#5
10/03/2004 (2:47 am)
Thanks,I will try.But I am new to C++,If resource code can be posted,It would be grateful.
#6
10/07/2004 (6:37 pm)
You've got to be kidding? You've got the turret, and you've got the vehicle... I did exactly what you wanted here... Also: Take a look at the readme that comes with the turret resouce, as it states how to do this as well.

[edit]
On second thought.... Are you a modeler/Animator? I'll trade code for art.
[/edit]
#7
10/07/2004 (7:34 pm)
Hi,Tim.I am not kidding.I buy Torque engine three months ago,I look at the readme comes with the turret resouce many times,I modify the vehicle class who's movement is only controlled by keyboard,but I can't let the turret controled by mouse.I try hard for it,but no result.So I want a "Tank pack".BTW,I don't know how to pay the resource code.genuinely.Thanks.
#8
10/07/2004 (7:46 pm)
What is your area of expertise? Moeling? Animating? Or just startin' out with coding/scripting?
#9
10/07/2004 (7:51 pm)
I Just want the coding/scripting.
a)control vehicle with keyboard.
b)control the turret with mouse,rotate around.
c)In 1st person view,looking where the turret is aiming.
#10
10/07/2004 (7:53 pm)
Blah - You gonna be online for another 20 minutes?
#11
10/07/2004 (7:56 pm)
I will be online for 5 hours.
#12
10/07/2004 (7:56 pm)
You got AIM, MSN, ICQ, IRC handy?
#13
10/07/2004 (8:00 pm)
MSN, eptyq2000@hotmal.com,or iRC.
#14
10/07/2004 (8:02 pm)
You sure about that spelling?
#15
10/07/2004 (8:04 pm)
In IRC, #GG, I'm Raverix
#16
10/07/2004 (8:06 pm)
SORRY.eptyq2000@hotmail.com.
#17
10/07/2004 (9:09 pm)
Thanks Tim,great help from you.
#18
10/07/2004 (10:05 pm)
Why not make it a new resource adding to "Turret & AITurret classes, Version 1.20"?
#19
10/07/2004 (10:17 pm)
Hi Tim,I get the following error:


--------------------Configuration: Torque Demo - Win32 Debug--------------------

Compiling...
vehicle.cc
D:\torque\engine\game\vehicles\vehicle.cc(473) : error C2065: 'turret' : undeclared identifier
D:\torque\engine\game\vehicles\vehicle.cc(842) : error C2227: left of '->updateMove' must point to class/struct/union
D:\torque\engine\game\vehicles\vehicle.cc(1466) : error C2039: 'setMountedTurret' : is not a member of 'Vehicle'
d:\torque\engine\game\vehicles\vehicle.h(125) : see declaration of 'Vehicle'
D:\torque\engine\game\vehicles\vehicle.cc(1467) : error C2440: '=' : cannot convert from 'class Turret *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\torque\engine\game\vehicles\vehicle.cc(1477) : error C2039: 'setMountedTurret' : is not a member of 'Vehicle'
d:\torque\engine\game\vehicles\vehicle.h(125) : see declaration of 'Vehicle'
Error executing cl.exe.

torqueDemo_DEBUG.exe - 5 error(s), 0 warning(s)
#20
10/08/2004 (7:39 am)
I'm posting this real quick... and it's copy pasted directly from the MSN chat I had with tyq.fk, so forgive it's crudeness...

Vehicle.h Changes:

Find:

#ifndef _BOXCONVEX_H_
#include "collision/boxConvex.h"
#endif


Add BELOW:

#ifndef _TURRET_H_
#include "game/turrets/turret.h"
#endif



Find (in class Vehicle: public ShapeBase):

ParticleEmitter *mSplashEmitterList[VehicleData::VC_NUM_SPLASH_EMITTERS];

Raverix Roshak says:
Add BELOW:
Turret * turret;

Find:
void mountObject(ShapeBase* obj, U32 node);

Add BELOW:
void setMountedTurret(Turret *obj);


---------------------------------------------------------------------------------------------------------------

Vehicle.cc Changes


Find:

waterWakeHandle = 0;

Add Below:
turret = NULL;


Find:
void Vehicle::mountObject(ShapeBase* obj, U32 node)

Add this below the mountObject function:

void Vehicle: etMountedTurret(Turret *obj) {
turret=obj;
}


ConsoleMethod( Vehicle, setMountedTurret, bool, 3, 3, "(ShapeBase obj)"
"set the turret to the vehicle.")
{
Turret *target;
if (Sim::findObject(argv[2],target)) {
object->setMountedTurret(target);
Con::errorf("ConsoleMethod End");
return true;
}
return false;
}


Find:

void Vehicle::updateMove(const Move* move)
{
mDelta.move = *move;


Add BELOW:

if (turret)
turret->updateMove(move);



----------------------------------------------------------------------------------------------------------------------------


Script Changes:

This depends on what you want.... the following will add a turret to eveyr vehicle...
You can change this to WheeledVehicleData:: or whatever.

function VehicleData::onAdd(%this,%obj)
{
%turret = new Turret()
{
dataBlock = GenericTurret;
};

%obj.mountObject(%turret,1);

%obj.mountedTurret = %turret;
%obj.setMountedTurret(%turret);
%camera.setTransform(%turret.muzzlepoint);
}
Page «Previous 1 2 3 Last »