Mounted turret help
by Adam Beer · in Torque Game Engine · 05/12/2008 (5:48 pm) · 9 replies
I have managed to mount a turret to a vehicle using this resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345
And I have also allowed a player to control the turret when he is mounted to a certain point. The problem I am having is when the player controls the turret, they arent mounted to it and they dont move with it, so the view doesnt shift with the turret making it impossible to aim it. How would you set the players view to the turret so you can aim it?
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5345
And I have also allowed a player to control the turret when he is mounted to a certain point. The problem I am having is when the player controls the turret, they arent mounted to it and they dont move with it, so the view doesnt shift with the turret making it impossible to aim it. How would you set the players view to the turret so you can aim it?
About the author
Adam is the owner of Ignition Games, an indie game and software development company.
#2
05/12/2008 (8:00 pm)
Right now the player controls the turret when hes mounted to the vehicle. The problem is, the player is mounted to the vehicle not the turret, so you cant really see the turret move and you cant aim it. I just want to be able to be able to aim the turret, and not have the player just sit in the vehicle while he controls the turret.
#3
Open shapeBase.cc and goto the function ShapeBase::getCameraTransform
After:
ADD:
That will fix the third person camera.
Now, in the same file and same function, look near the end of the function and change...
To:
You will now be able to mount to any point and the camera will "track" the object you are controlling.
05/12/2008 (8:17 pm)
Ok. This is a slight mod to this thread.Open shapeBase.cc and goto the function ShapeBase::getCameraTransform
After:
if (isServerObject() && mShapeInstance)
mShapeInstance->animateNodeSubtrees(true);
if (*pos != 0)
{ADD:
// begin change ... use 3rd person came of vehicle when mounted
// special thanks: M.T. Maas
if ([b]mControlObject[/b])
{
[b]getControlObject()[/b]->getCameraTransform( pos, mat );
return;
}
// end changeThat will fix the third person camera.
Now, in the same file and same function, look near the end of the function and change...
else
{
getRenderEyeTransform(mat);
}To:
else
{
if([b]mControlObject[/b])
[b]getControlObject()[/b]->getRenderEyeTransform(mat);
else
getRenderEyeTransform(mat);
}You will now be able to mount to any point and the camera will "track" the object you are controlling.
#4
error C2065: 'mControlObject' : undeclared identifier
I am using TGEA 1.07, but that shouldnt really matter for this change, should it?
05/12/2008 (8:40 pm)
Ok I added that but I am getting this error:error C2065: 'mControlObject' : undeclared identifier
I am using TGEA 1.07, but that shouldnt really matter for this change, should it?
#5
should be getControlObject() instead of mControlObject.
Tried to do it from memory.
Just had to rechecked my code.
05/12/2008 (8:59 pm)
Whoops my mistake.should be getControlObject() instead of mControlObject.
Tried to do it from memory.
Just had to rechecked my code.
#6
05/13/2008 (8:08 am)
Ok the code works, the view does change, but for some reason when I am mounted to the one node that controls the turret, it doesnt move and the view is all weird. If I want to be bale to move the turret, I have to go into the editor and exit the editor again and then the turret will move, but the camera just stays where it is.
#7
1. Make sure your turret has a "eye" node attached to the barrel or whatever you want to sight down.
2. By changing the code the camera will now track with the camera offset info in the datablock and will lag based on the camera info in the datablock. You may have to define some values.
05/13/2008 (9:42 am)
A couple of things.1. Make sure your turret has a "eye" node attached to the barrel or whatever you want to sight down.
2. By changing the code the camera will now track with the camera offset info in the datablock and will lag based on the camera info in the datablock. You may have to define some values.
#8
05/13/2008 (5:53 pm)
Thanks so much Bill, it works now. The only issue I have now is the turret doesnt start moving untill I go into the editor and exit out of it. I am thinking its a issue with binds, but why does it start to work after I enter and exit the editor? Any ideas?
#9
If you use the turret as a stand alone object , not attached to the vehicle, does it do the same thing?
05/13/2008 (7:02 pm)
I don't recall running into that problem when I did it.If you use the turret as a stand alone object , not attached to the vehicle, does it do the same thing?
Torque Owner Bill Vee