Thursday, July 29, 2010

Physics work better on the Moon!


It looks like Torque works better in low gravity :)
The trick was to leave the engine to calculate mass and inertia of the colliding objects by itself (look for an appropriate checkbox) , rather than blindly fiddling with values.
The gravitational force was also decreased by half, so the ship can move more swiftly.







What it also worth noting is that it took me about 7 minutes to create Moon-like landscape, including drawing graphics from scratch, importing them into the editor, rotating, scaling and equipping with the collision mesh and placing on the level map.

Wednesday, July 28, 2010

Abduction ray and physics problem

Another day, another mountain to climb. Looks like my physics settings are not working too good. Or is it about my settings? Apparently some object decide to penetrate into 'solid' walls and floors. No clue at the moment, as the physics rules seem to hold for some situations.

On the positive side - the approach I took to implement abduction ray seems to be a correct one. The movie doesn't show it, but abduction ray detects collision with ovals as designed. Because ship and abduction ray detect collision of different collision layer it was important to make sure, that the ray is not coliding with the ship.

Sunday, July 25, 2010

First iteration of game physics - coding with TGB day 2

The emerging game physics looks better that I was expecting. There is a lot of things going on behind the scene: 
- tilting the ship depending on the current velocity and previous rotation,
- bouncing when trying to land on objects other than landing platform on when colliding,
- decreasing ship condition after each impact (not exposed to the GUI jet).


 The 'tilting' code so far is very simple:

function player::onUpdate()
{
    %desiredRotation = $player.getLinearVelocityX() ;
    %newRotation = %desiredRotation - $player.getRotation();
    $player.setRotation( $player.getRotation() + %newRotation / 10 );
}

Although it took me a while to figure out, that to enable onUpdate() calls one has to do the following:

$player.enableUpdateCallback();

Learning the hard way ;)

Saturday, July 24, 2010

Exposing object's linear velocity during collision.

Prototyping with TGB is very easy and straightforward process. Afret first 30 minutes I have my UFO and a few objects to colide with.



Some extra code was needed though to expose UFO's linear velocity to the script, so that I will be able to calculate impact damage during collision.

I added the following code to the t2dPhysics::resolveClampCollision method, at the end of if ( solveDst ) statement:

// notify the colliding object about its linear speed during impact 
F32 currentCollisionSpeed = linearVelocity.len();
Con::executef( 
   pCollisionStatus->mDstObject, 
   2, 
   "processCollisionImpact",
   Con::getFloatArg(currentCollisionSpeed) 
);
That way every time my UFO hits another object, the following script funcion will be called:

function player::processCollisionImpact( %this, %collisionSpeed )
{
}

The Beginning

I have been toying with the idea of creating a game for iPhone for some time now. Since I currently do not own neither iPhone nor any Mac machine (I am a PC for that matter), prototyping on my old, Windows driven notebook seems to be the right idea. I am also too busy a man to start from scrach, so I decided to give a try Torque Game Builder, which should allow me a flying start (so at least I hope).

 The idea for my games is very simple really - ALIEN ABDUCTION :), which will be based on very nice flash game: http://www.miniclip.com/games/ufo-joe/en/