Game Development Community

New vehicle type

by Phillip O'Shea · in Torque Game Engine · 02/01/2008 (1:21 pm) · 2 replies

Hi, my name is Phil and I'm a TGE newbie.

I am working on a small game similar to Wii Play's Tanks! I would like to create a basic moving tank at this stage, not particularly interested in the turret movement, just getting the tank to move around nicely. In case you haven't seen Tanks!, it is an overhead game where you drive your tank around blowing other tanks up. Moving the control stick in each direction rotates the tank to face that direction and then start moving.

I have purchased the Tank Pack, but I feel it has a lot of things that make life complicated and the code is dated in comparison to the other vehicles.

How do I get started? I have had a quick look at the vehicle data and I think the for the most part I should create a new type of vehicle. Should I use the Vehicle class as my parent, or use one of the others? I don't plan on adding wheels to my tank.

I set about doing this (using the Vehicle class as my parent), got the tank into the game and was puzzled on how to apply gravity to the tank. I shuffled through the other vehicle code and then applied gravity in the "updateForces" function. The tank now lands on the ground firmly, working well at this stage.

My newest problem, how on earth do I get the tank to move (just forwards and backwards at this stage would be sufficient)? I just cannot figure it out!

Any help is very appreciated!

About the author

Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.


#1
02/01/2008 (2:43 pm)
Hello Phil, I think you would want to look at this resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5474

It may, I think help you work out how you can get your tank to move as you would expect from a different view. But not sure if you want this?

With getting the tank to move etc, I would look around at all the turret resources and the forum posts about that. Some maybe handy, as people are creating tanks like you.
#2
02/01/2008 (2:59 pm)
Thanks Edward, it looks as if it will come in handy. However, I cannot even get it to move when applying velocity to the object.

It uses rigid physics, but I cannot find out how to actually apply velocity to the tank. I've tried:

mRigid.linVelocity
mRigid.linMomentum

Failing that, I directly modified the position of the tank, but it ignored collisions, so velocities are the only way.

This is the code that I am attempting to use:

void TankVehicle::updateForces(F32 dt)
{
    //
    MatrixF currMatrix = getTransform();
    
    if (mThrottle)
    {
        Point3F y;
        currMatrix.getColumn(1, &y);
        
        Point3F linVelocity = mThrottle * y * 5.0f;
        //mRigid.force += linVelocity;
        mRigid.linVelocity += linVelocity;
        
        mRigid.atRest = false;
    }
}

Movement seems like a really basic thing to do, I just can't get it to work.