Turret Resource With Vehicles
by Robert Fritzen · in Torque Game Engine Advanced · 12/04/2010 (11:04 pm) · 7 replies
Hello,
Well, it looks like I'll be using TGEA for now (seeing as T3D is a little high end for my laptop). But, that's not that big of a problem for me. TGEA is still really good.
Anyways, onto my question.
I've implemented the Turret resource into TGEA 1.8.1 (http://www.torquepowered.com/community/resources/view/5345), and then added the following changes as well(http://www.torquepowered.com/community/forums/viewthread/21812). And now I am experiencing what everybody else is calling the "glitchy" turret situation, movement on it is pretty choppy.
I looked around and read a few things, but not much is coming as a "solution" to me. I'm really looking forward to using this engine to make a multiplayer tank combat game, and seeing as I've already implemented an authentication and a listing server setup, It would seem as the challenging parts are slowly heading out the door. Anyways, is there any easy way of fixing the choppy turrets. I read somewhere about adding a "custom" movemap specific for the tanks, if that would work, how would I go about adding it?
Any help qould be appreciated,
Robert.
Well, it looks like I'll be using TGEA for now (seeing as T3D is a little high end for my laptop). But, that's not that big of a problem for me. TGEA is still really good.
Anyways, onto my question.
I've implemented the Turret resource into TGEA 1.8.1 (http://www.torquepowered.com/community/resources/view/5345), and then added the following changes as well(http://www.torquepowered.com/community/forums/viewthread/21812). And now I am experiencing what everybody else is calling the "glitchy" turret situation, movement on it is pretty choppy.
I looked around and read a few things, but not much is coming as a "solution" to me. I'm really looking forward to using this engine to make a multiplayer tank combat game, and seeing as I've already implemented an authentication and a listing server setup, It would seem as the challenging parts are slowly heading out the door. Anyways, is there any easy way of fixing the choppy turrets. I read somewhere about adding a "custom" movemap specific for the tanks, if that would work, how would I go about adding it?
Any help qould be appreciated,
Robert.
About the author
Illinois Grad. Retired T3D Developer / Pack Dev.
#2
I'll post back when I get the second thing done to see if that helps.
*Edit*
I read through the second link a little more, and tried out Micheal's suggestion (Post #27/#28) and I'm not entirely sure or not (I'll have some of my friends see if they notice any difference), but from what I see, that looks to have fixed it.
12/08/2010 (12:38 am)
I'll give the second part a try and see if that works. As for the first part, I'm not quite sure how to go about fixing that.I'll post back when I get the second thing done to see if that helps.
*Edit*
I read through the second link a little more, and tried out Micheal's suggestion (Post #27/#28) and I'm not entirely sure or not (I'll have some of my friends see if they notice any difference), but from what I see, that looks to have fixed it.
#3
I can get the player now mounted to the turret correctly, but a new problem has shown itself to me.
The turret with player in it does not mount to my vehicle, instead it just sits somewhere on the map. Good news is, looking at the player/turret from inside my vehicle (lol), is that the movement of the turret is as smooth as it will be, so that issue is fixed.
here's my current code:
If I'm missing something you need me to show that might help fix it, please let me know.
I'll keep cracking at this, unless you find one of my "silly mistakes" somewhere in it.
12/13/2010 (7:57 pm)
More progress.I can get the player now mounted to the turret correctly, but a new problem has shown itself to me.
The turret with player in it does not mount to my vehicle, instead it just sits somewhere on the map. Good news is, looking at the player/turret from inside my vehicle (lol), is that the movement of the turret is as smooth as it will be, so that issue is fixed.
here's my current code:
If I'm missing something you need me to show that might help fix it, please let me know.
//creation of vehicle
function DefaultCar::onAdd(%this,%obj) {
%obj.mountable = true;
// Setup the car with some defaults tires & springs
for (%i = %obj.getWheelCount() - 1; %i >= 0; %i--) {
%obj.setWheelTire(%i,DefaultCarTire);
%obj.setWheelSpring(%i,DefaultCarSpring);
%obj.setWheelPowered(%i,false);
}
// Steer front tires
%obj.setWheelSteering(0,1);
%obj.setWheelSteering(1,1);
// Only power the two rear wheels...
%obj.setWheelPowered(2,true);
%obj.setWheelPowered(3,true);
//turret
%turret = new Turret() {
dataBlock = GenericTurret;
};
%turret.base = %obj;
%obj.mountObject(%turret, 0);
%obj.mountedTurret = %turret;
%obj.setMountedTurret(%turret);
%turret.setMountedVehicle(%obj);
%obj.cl.camera.setTransform(%turret.muzzlepoint);
}
//Vehicle Spawning
function CreatePlayerTank(%client, %spawnPoint) {
%tankName = %client.TankName;
%tank = $Tank::NameToBlock[""@%tankName@""].create(); //Handles creation of tank/turret
MissionCleanup.add(%tank);
%client.tank = %tank;
%tank.cl = %client;
%tank.client = %client;
%tank.team = %client.team;
%tank.setTransform(vectorAdd(%spawnPoint, "0 0 10"));
%player = new Player() {
datablock = PlayerBody;
};
%client.setControlObject(%player);
MissionCleanup.add(%player);
%player.setPosition(%tank.getPosition());
%player.schedule(50, "mountObject", %tank.mountedTurret, 1); //tried node "0" too, still does the same
%client.player = %player;
//Control the turret
//%tank.mountedTurret
//%client.setControlObject(%player);
return %tank;
}I'll keep cracking at this, unless you find one of my "silly mistakes" somewhere in it.
#4
12/13/2010 (8:09 pm)
I may be wrong, but I think you're mounting the turret to the player:%player.schedule(50, "mountObject", %tank.mountedTurret, 1);
#5
Thanks Daniel, works great now.
12/13/2010 (8:49 pm)
hahaha, wow, now that's a stupid mistake on my behalf. :DThanks Daniel, works great now.
#6
12/14/2010 (7:06 am)
That's what peer-review is for ;). Good to know it's all working!
#7
So, now a new issue has come up. I wanted to try the other example of making a PlayerObject be the turret instead, but now three issues have come up. I know people have solved this issue in the past, so I'd like some input on how to get this working from someone who has accomplished this. I don't mind having to re-do my system if it's just not working entirely, I just want it working (I'll go back to using TurretObjects if I must).
These are the issues:
1. I can't mount my turret's "weapons" to the player for some reason, even though the code is correct.
2. The rotation of the player acts as a player model instead of a turret, and rotates around the vehicle, not in place.
3. And lastly, once again, I can only control one or the other.
NOTE: I'll be open on Friday if someone would like to help me work this out on IRC. Just let me know before hand.
EDIT: Was busy Friday, I'll try for sometime this week. (Not to sound like I'm demanding help), Is there anything you'd suggest I have with me before I come onto IRC?
06/15/2011 (12:36 pm)
Apologies for reviving this old thread, but apparently I was wrong (again). This issue is still here with the system I had implemented above (my gui refuses to render), so I started to recode some things and realized that the movement was indeed choppy when I set myself to only control the turret and got perfectly smooth movement.So, now a new issue has come up. I wanted to try the other example of making a PlayerObject be the turret instead, but now three issues have come up. I know people have solved this issue in the past, so I'd like some input on how to get this working from someone who has accomplished this. I don't mind having to re-do my system if it's just not working entirely, I just want it working (I'll go back to using TurretObjects if I must).
These are the issues:
1. I can't mount my turret's "weapons" to the player for some reason, even though the code is correct.
2. The rotation of the player acts as a player model instead of a turret, and rotates around the vehicle, not in place.
3. And lastly, once again, I can only control one or the other.
NOTE: I'll be open on Friday if someone would like to help me work this out on IRC. Just let me know before hand.
EDIT: Was busy Friday, I'll try for sometime this week. (Not to sound like I'm demanding help), Is there anything you'd suggest I have with me before I come onto IRC?
Torque Owner Daniel Buckmaster
T3D Steering Committee
First and most obviously, the Turret class from that resource has no warping code. This means any time the server sends an update, the turret on the client will appear to snap to the correct rotation, rather than travelling there smoothly from its old position. This can be a problem depending on how big the discrepancy is between server and client simulations. If your client-side turret isn't ever being moved by your character's inputs (i.e., it relies on the server to tell it everything), then movement will be extremely choppy (at about a frequency of 1Hz, at least that's what I've seen).
Second, it could be a problem with writePacketData not being called on the turret, even when it's called on the vehicle. I'm not sure if this is as relevant, or even an actual issue. You might even be able to fix it up by making the Turret the Vehicle's control object, as someone suggested (so the hierarchy would go Player -> Vehicle -> Turret).
I don't think the move map is an issue at all here. If you can get processTick (for both Player and Vehicle) to pass inputs to controlled objects correctly, you'll be fine with the standard keyboard and mouse binds - of course, unless you want more detailed controls, such as having separate keys for turret and vehicle yawing.