Game Development Community

HELP! I dont want flyer to dive/climb

by Guimo · in Torque Game Engine · 07/19/2006 (9:32 am) · 8 replies

Hi,
I'm just a beginner with Torque but slowly learning. I'm having a problem here, hope you can help...
I'm trying to create an Asteroids clone, with a top view but with 3d objects everywhere. I don't want to use TGB... its a TGE learning experience.

Then... all the action will happen in a single plane above the ground. I don't want objects to dive or climb in altitude. Also, controls will be keyboard/gamepad only... no mouse, no keyboard.

In order to reach the problem:
a. Start with the starter.racing mod.
b. Change the Car for a Flying Vehicle as described at: http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5071
c. Remove pitch and yaw from mouse control. Leave yaw from keyboard.

Now, when the game starts I move left/right and the ship turns... thats ok.
Then I press the forward key (up arrow) to gain some speed and then I press left/right. In that moment the ship tilts and starts diving. And as I dont have mouse control its impossible to climb (and I don't want mouse control).
And Thats the problem... I don't want the ship to dive or climb. I want it to go forward and turn left/right.

So I tried the FlyingVehicle and HoverVehicle objects.
The movement of the HoverVehicle is harder and doesn't tilt when I turn left/right so it looks a little unnatural. Also it likes to stick to the ground (I guess I can modify this tweaking the engine a little).
The movement of the FlyingVehicle is better and I can define a default hover altitude (funny... the hoverVehicle doesn't support hover altitude). The problem is that it dives when turns left/right.

I tried many settings like removing the wing 'bite' param form the datablock and other values. I even tried to get some help from the autopilot but no use.
Then I tried to mess with the engine adjusting the gravity parameter to 0 for the flying vehicle. No use.

So I don't know where to look now. I mean... This shouldn't be that hard to do... please help me!!!

Luck!
Guimo

#1
07/27/2006 (6:42 am)
Have you found the solution for this?
#2
08/07/2006 (11:13 pm)
No... I managed to remove the air bite so the vehicle turns horizontally but won't bank left or right. It doesn
#3
08/08/2006 (12:21 am)
Hmmm... Can you just retype the message without using the apostrophy...? I removed the bank and bite from my game. I will get the code and post it here on thursday. I want the bank back though
#4
08/08/2006 (8:06 am)
I forgot the rest of the message :)
As you mention, Ive tried many configurations for the flying vehicle. Whenever I enable the air bite the vehicle is allowed to bank but inmediatly starts going down when I thrust forward.

I guess I have to investigate and rewrite how physics forces are applied in the flyingvehicle.cc but just now I have another problem. It looks like the flying vehicle always falls from sky, no matter if my spawn point, and the starting hover height and even the hover height all have the value of 20 and the startHeightOn attribute is also enabled. It quickly levels at the desired height(20) but I'd like it to start at 20. More to investigate...

Luck!
Guimo
#5
08/11/2006 (12:28 am)
Okay... sorry for taking so long with the code, but I forgot to bring it yesterday. Please note that i'm pathetic when it comes to basic 3D math.

In flyingvehicle.cc in the function
void FlyingVehicle::updateForces(F32 /*dt*/)

Look for and change as nessacary:
// This is what moves us 
mRigid.force  = force;

//This causes the model to turn and roll etc.
//mRigid.torque = torque;
	
//First value is the Up/Down (or bite)
//Second value is the Roll (banking)
//Third value is the turning
mRigid.torque.set(0, 0, torque.z);

//Keep on the same plane Always!
mRigid.linPosition.z = 0;

So I just removed the bite and the the Banking... Because when you bank the left and right changes... So i'm a bit stuck here. I need my plane to bank. If I can't seem to get it right, i'm just gonna use animations.

Hope this helps a bit.
#6
08/11/2006 (1:13 am)
I'm no expert, (actually, still learning) but have you thought about using a transperant plane to make your "plane" collide with so that it won't go down? I don't know how that would work with the weapon unless you hung it under the collision plane tho. Just a thought.
#7
08/11/2006 (1:32 am)
That's an idea... But removing gravity and forcing the position on the z position works great for me...
#8
09/26/2006 (10:56 am)
Ive been studuing the Torque engine and feel more comfortable now.

As Im making a space game, its required to remove any drag caused by air. I managed to remove the air bite (horizontalSurfaceForce and verticalSurfaceForce) and the minDrag. That gave me the required movement but still can't bring the banking to work because the ship just goes down.

Removing the minDrag gave me some headaches as the max speed is linked to it, but I finally created a topSpeed attribute into the datablock and now all works fine (except the banking).

Your idea of forcing the z position in the updateForces method is a nice one. It works fine. I was thinking to edit the z component in the force variable in the FlyingVehicle::updateForces method so any force generated due to the ship banking+acceleration will become 0 and inmediately nullified.

Also I was playing a little with the applyImpulse function in order to zero the z component of the impulse so collisions won't launch me to strange directions.

Luck!
Guimo