Game Development Community

Jet Pack

by David · in Torque Game Engine · 03/09/2002 (8:13 pm) · 17 replies

I have been trying to figure out this for a long time and yet still havent fully figured this out. Does any one by any chance know how to add the jetpack ability like Tribes2? any advice would be appreciated.

sorry, for any miss grammers/ typos.

#1
03/09/2002 (9:11 pm)
There is a tutorial for this that was produced a few months back. Do a search on google, and you'll find it.
#2
03/09/2002 (10:05 pm)
that was a VERY cheesey jetpack though ;)
#3
03/09/2002 (10:17 pm)
do you remember the link? if not ill do a search either way by any chance you know of the name of the tutorial?
#4
03/10/2002 (12:22 am)
I don't know if it is the tutorial mentioned, but this one is some sort of cheesy quick hack: v12.ultimagroup.com/article.read.asp?article=18 ... but at least something to start with.
Haven't tried if it works, though...
#5
03/10/2002 (3:20 am)
It's really not that hard. All you have to do is change the jump code a little and it should be fine.

What I would do is make it an extention of the jump code. When you press jump, it jumps, then it jets while you hold it.

I might look into it. Right now I'm doing swim code, and it works about the same way, it just checks if you're underwater.
#6
03/10/2002 (10:56 am)
You can probably do it with script easily using "impluse" function.

Just add some length to the height movement vector (y axis? I always forget...) whenever you press the jetpack button. Just make sure that the length added is higher than the amount lost per tick to gravity otherwise you'll never get off the ground! Blam! You got a jetpack that is affected by gravity automatically!

Might want to tie it in with the mass of the wearer (afterall, a 30 pound guy would be flung around like a beach ball but a 200 pound guy would be slower to accelerate but much more stable in movement)

Yes, it is that simple! Now you have to link some smoke emitters and sounds to it, but the effect itself is pretty easy to get going!

Only problem is the game currently doesn't support forces applied when your player's feet are not touching the ground. A few simple code changes could fix this (so you can steer when in air with jetpack)

Have fun!
#7
03/10/2002 (12:11 pm)
Test Guy could really use a jetpack.
#8
03/10/2002 (8:25 pm)
Thanks for all the replies they are a great deal of help. If there is anything else you would like to add please dont hesitate to post it here.
#9
03/10/2002 (11:54 pm)
Here's a quick hack. Put it in player.cc under updateMove.

if (move->trigger[2] && !isMounted()) 
	{
		VectorF pv;

		Point3F headRotation = getHeadRotation();
		pv = moveVec;
		pv *= moveSpeed;

		VectorF jetAcc = pv - (mVelocity + acc);
		F32 jetSpeed = jetAcc.len();

		F32 maxJetAcc = (mDataBlock->runForce / mMass) * TickSec;

		// the 0.25 multiplyer is a hack to reduce the verticle force. Remove it and you turn into a rocket.
		jetAcc.z += ((headRotation.x * -1) * (mDataBlock->runForce / mMass) * 0.25f);

		if (jetSpeed > maxJetAcc)
			jetAcc *= maxJetAcc / jetSpeed;
		acc += jetAcc;

		setActionThread((mVelocity.len() < 0.5) ? PlayerData::StandJumpAnim : PlayerData::JumpAnim, true, false, true);
	}

Put it underneath the jump code:

// Acceleration from Jumping
   if (move->trigger[2] && !isMounted() && canJump()) 
   {
      // Jump code...
   }
   else
      if (jumpSurface) {
         if (mJumpDelay > 0)
            mJumpDelay--;
         mJumpSurfaceLastContact = 0;
      }
      else
         mJumpSurfaceLastContact++;

   // insert Jet code here.

It doesn't take any energy away from the player. And it's not like the T2/T1 jetpack. Hold jump to use it. If you look up, you move up, if you look down you move down. You control the forward/backward/side motions with your forward/backward/side keys.

You should probably add a Player::canJet() function (like the Player::canJump() function).

Remember, this was originally made as swim code, so it's not exactly perfect as a jetpack. I removed the swimForce variables and replaced them with runForce. You should probably add jetForce, and some jetEnergy code. This should help you get a good starting point.
#10
03/11/2002 (9:08 am)
thanks alot this is really a great help. :)
#11
03/11/2002 (11:17 am)
can some one explain this a little more i dont seem to understand exactly where to put this stuff cuz when i recompile it i get no errors but nothing seems different ingame,,,,,do i have to have some script some wheres to make it work?
#12
03/11/2002 (11:21 am)
Trigger 2 = jump, so it should work when you press and hold down the jump button.

I haven't tried it, but try a full rebuild and see. That usually fixes stubborn things that don't seem to show up when i recompile.
#13
03/11/2002 (8:39 pm)
Is it possible to use the t2 script code to add the jet pack ability to torque? if so can some one please give a detailed explination on how to achieve this?

Thanks for taking time to help others.
#14
03/11/2002 (8:42 pm)
Maybe you can. We don't have the script code to look at, so unless you provide it we're not going to be much help.

Not all of us have Tribes 2! So keep that in mind when you refer to stuff that is in that (and not Torque)
#15
03/12/2002 (12:05 am)
T2's jetpack isn't done in script.

The T2/T1 jetpacks give a boost in the direction they're moving. If they're holding forward, and the jet key then they'll either rise very slowly while going forward, go straight ahead, or lose altitude while going forward. It depends on the object's mass and jetforce.

Think of it as a real jet. The object goes in the oppisite direction of the jet nozzle.

Unless I'm mistaken, they still have another trigger in there that you can use for the jetpack. It would probably be better.

In fact, maybe I'll just go ahead and do it.
#16
03/12/2002 (8:16 am)
some one should submit this in a more explainable tutorial,,,(cuz it took me awhile to figger it out)it should look somthing like:
=================
JetPack2 Tutorial
=================

Jetpack-like behavior for jumping with forward motion
when holding down the jump and moveforward keys.

the code you need to add is bold


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

The first step is to remove the jump delay and the restriction that a player can only jump when he is touching the ground. In \engine\game\player.cc:

Line 1464, replace:

mJumpSurfaceNormal = contactNormal;

with

mJumpSurfaceNormal.set(0,0,1);

and then, on line 1700, replace

return mState == MoveState && mDamageState == Enabled && !isMounted() && !mJumpDelay && mEnergy >= mDataBlock->minJumpEnergy && mJumpSurfaceLastContact < JumpSkipContactsMax;

with

return mState == MoveState && mDamageState == Enabled && !isMounted() /*&& !mJumpDelay*/ && mEnergy >= mDataBlock->minJumpEnergy /*&& mJumpSurfaceLastContact < JumpSkipContactsMax*/;


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

//and to get forward motion still in player.cc
// Acceleration from Jumping
if (move->trigger[2] && !isMounted() && canJump())
{
// Jump code...snipped
}
else
if (jumpSurface) {
if (mJumpDelay > 0)
mJumpDelay--;
mJumpSurfaceLastContact = 0;
}
else
mJumpSurfaceLastContact++;

// insert Jet code 0n about here. line 1574
if (move->trigger[2] && !isMounted())
{
VectorF pv;

Point3F headRotation = getHeadRotation();
pv = moveVec;
pv *= moveSpeed;

VectorF jetAcc = pv - (mVelocity + acc);
F32 jetSpeed = jetAcc.len();

F32 maxJetAcc = (mDataBlock->runForce / mMass) * TickSec;

// the 0.25 multiplyer is a hack to reduce the verticle force. Remove it and you turn into a rocket.
jetAcc.z += ((headRotation.x * -1) * (mDataBlock->runForce / mMass) * 0.25f);

if (jetSpeed > maxJetAcc)
jetAcc *= maxJetAcc / jetSpeed;
acc += jetAcc;

setActionThread((mVelocity.len() < 0.5) ? PlayerData::StandJumpAnim : PlayerData::JumpAnim, true, false, true);
}


----------------------------------------------------
#17
03/13/2002 (10:52 am)
Do you know how you would add a particle emitter so when you activate the jet pack it emits particles and when you halt using the jet pack the emitters would cease to emit particles?