Andrew

April 29, 2008

Tribes 1 Physics, Part Four: Explosions

Filed under: Games,Tribes — floodyberry @ 12:30 pm
Tags:

Explosions (or more accurately, knockback), the final piece to the physics puzzle! If you implement all of the previous articles, make a disc launcher, plug in the apparently simple knockback force and radius from baseProjData.cs, and finally attempt to disc jump, you will be greeted with… a nice and wimpy boost. Playing around with the knockback force will only break explosions in new ways. Argh, you were so close! How could Tribes possibly screw this one up?

Basic Knockback

The basic idea for knockbacks from explosions is you want to take the position of the explosion and the object, scale the explosion force, and apply an impulse to the object in the appropriate direction. Generally this is implemented something like so:

Player.onExplosion( Vector3 explosion, float radius, float knockback, float damage ) {
    Vector3 distance = ( hitbox.center - explosion ), direction = distance.Normalize
    if ( distance.Length > radius )
        return

    float power = 1 - ( distance.Length / radius )
    ApplyDamage( power * damage )
    ApplyImpulse( knockback * ( power * direction ) / armor.Mass )   
}

power is where the magic happens and while it should be an exponential falloff, it is common to do linear because there is not much of a noticeable difference. It is also where Tribes deviates from the norm in a fairly big way.

Tribes Knockback

What is obvious when you implement the basic knockback is that it packs a much smaller punch than Tribes. What you might not notice is that the Tribes knockback up close, e.g. at your feet from a standstill, is actually weaker than from a bit of a distance, e.g. at your feet while you’re in the air after jumping. Whether this was intended as an aid to disc jumping or an accident of a botched formula is impossible to say, but it doubtless would have been harder to gain speed from disc jumps without this odd feature.

If you work out exactly what the Tribes knockback function does (not fun) and re-factor the formula (not fun and also confusing), you come out with a somewhat familiar power calculation. Instead of the basic ( 1 – ( d / r ) ), Tribes uses ( ( d / Max( d – minHitboxDimension, 1 ) ) – ( d / r ) ), i.e. instead of using a constant ( 100% – linear falloff ) for the power, Tribes does some weird calculations which I can only guess are trying to account for the hitbox in some way. This image illustrates the power falloff for Tribes, the power falloff for the basic formula, and the power falloff for the basic formula if it were boosted so players were able to disc jump properly:

This shows why the linear falloff formula cannot be fixed by boosting the knockback force without getting wildly inaccurate up close. Here is the proper formula:

Player.onExplosion( Vector3 explosion, float radius, float knockback, float damage ) {
    Vector3 distance = ( hitbox.Center - explosion ), direction = distance.Normalize
    float minbox = Min( Min( hitbox.Width.x, hitbox.Width.y ), hitbox.Width.z )
    float d = Max( distance.Length - minbox, MetersToUnits( 1 ) )
    if ( d > radius )
        return

    float power = ( distance.Length / d ) - ( distance.Length / radius )
    ApplyDamage( damage * ( 1 - d / radius ) )
    ApplyImpulse( knockback * ( power * direction ) / armor.Mass )   
}

For the Light Armor with a BOX_WIDTH of 0.5, BOX_DEPTH of 0.5, and BOX_HEIGHT of 2.3, minbox equates to Min( Min( BOX_WIDTH * 2, BOX_DEPTH * 2 ), BOX_HEIGHT ), or 1.0. The player origin is at the center of the player’s feet and the hitbox dimensions extend out from that, so the width and depth extend out in either direction and need to be doubled while the height goes from the feet to the head. Note that if you increase the smallest hitbox dimension, e.g. increase BOX_WIDTH and BOX_DEPTH to have a value of 2.3 when doubled, the linear ramp leading up to the downward falloff of the power will grow, presumably to account for greater surface contact area with the explosion.

You’re Done!

You should have all you need to get authentic Tribes 1 Physics going in your engine of choice! After this you should only need to create some dummy weapons, scale their velocities to whatever units you are using, add two flags, and you can get an honest game of LT going.

What? You don’t believe me that it works and you don’t want to waste your time implementing the physics only to find out that I lied? Hmmm, here’s something that should convince you. This is the full T1 physics running on Raindance in ET:QW. I did this for the ET:QW Tribes mod that was in the works, but unfortunately things kind of fizzled out. The map is authentic Raindance (every crevasse and triangle is there) with an 8192×8192 command map texture overlaid on top with Arcanox’s bases and bridge. This is currently the closest thing to Tribes you will ever see in another engine.

You can also download the hi-res version (15mb), although the burps are more apparent since my computer wasn’t quite up to spec to run QW. How I got the terrain in and textured will have to wait for another day.

Tribes 1 Physics Series

6 Comments »

  1. i am very interested in learning more about the game engine, can you help me out?
    i want to know more about the physics and inner workings, i play tribes almost
    every day, tried some mapping, stared at scripts for a bit, need some help though,
    i suppose you and KT are comrades, i hear a lot about his abilities, wish i could
    follow that path, i want to know limits of gameplay, what is possible/what isn’t,
    for example i want to know if there is a way to add function of heat seeker missile
    to regular bullets, i tried some cut and paste but no luck, please let me know if
    there is any way you can help, thanks

    Comment by COPE — October 14, 2008 @ 2:16 pm | Reply

  2. I don’t know much about modding like that or what the limits of the engine are in that regard.

    You should try http://annihilation.info/forum/, guys like Plasmatic are the ones who have done insane things with the actual gameplay. If anyone knows what’s possible, it’d be him.

    Comment by floodyberry — October 14, 2008 @ 5:40 pm | Reply

  3. CS players: several thousands
    UT players: several thousands
    Q3 players: thousands
    T1 players: tens
    What does this tell us?

    Simply that the myriad games released since Tribes being played by hundreds of thousands if not millions of people worldwide indicate that the vast majority of online game players do not know of, care about, or need skiing and T1 physics. No one is waiting for T1 to come out on a console. I found your rendition of t1 physics on etqw reminds me more of the Tribes Vengeance version of Raindance than anything else… Your blogging has interesting tidbits about a dying game though.

    Comment by an admirer — March 14, 2009 @ 10:54 am | Reply

  4. To the guy above, many games are dying however having the most knowledge about what made the games successful is what is the most important part. Yes Tribes might be dying but that doesn’t mean their physics engine or concepts were bad, it just means the game is getting old. Sometimes the older game concepts actually make a comeback and those familiar with it will be great full.

    Keep up the good work Andrew, I am trying to implement some of the physics in my game I am making :D

    Comment by Chris — April 15, 2009 @ 12:37 pm | Reply

  5. Nice work although I don’t think I understood a thing xD

    I heard you were working on the “Browser Tribes” thing. What happened to it?

    Comment by Ozone — October 6, 2009 @ 2:17 am | Reply

  6. Say it is not so! I was looking forward to the Tribal War mod, so I purchased Quake War only to find this blog and discover it is over. I wish it has been announced on the actual Tribal War site.

    @admirer, whatever, from the vids this is the closest I have seen to Tribes physics. And your comparison to other games of the time is unfair given the restrictive mapping and modibility of the original tribes. Had the engine been as mod friendly as the games you listed, there would still be a thriving community behind the game. I think that is part of the impetus behind the Tribal War project; to update the graphics and make it more “friendly” to modification. There is no game out there that can compare to the original Tribes.

    Andrew, are there any plans to open up the source on this project so others may continue it?

    Comment by G33kB0n1X — October 24, 2009 @ 10:03 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.