Game Development Community

dev|Pro Game Development Curriculum

Top Down Shooter/Bird Eye's View Example T3D (Script)

by Glenn Bermingham · 01/30/2011 (7:53 am) · 4 comments

Works as good as the standard FPS Example on Multiplayer.

Before we start I highly recommend doing this on a fresh copy of Torque 3D Full example. After each step you can save and test your current progress in game.

1. Top Down Camera and locking it there
Art/datablocks/player.cs

scroll down to:
datablock PlayerData(DefaultPlayerData)

change each individual setting in the datablock:
cameraMaxDist = 3;
   minLookAngle = -1.4;
   maxLookAngle = 1.4;

to
cameraMaxDist = 9;
   minLookAngle = 1.4;
   maxLookAngle = 1.4;

This'll zoom our third person camera right out and lock the camera on a 90 degree angle, also note that maxLookAngle is the same as minLookAngle rather then being a negative number. You can change these settings at your discression for your own zoom and camera angle effect, just make sure min and max LookAngle are the same numbers as each other.

(Test!: Press Tab to toggle to third person!)

2. Getting the player to shoot on a 2D plane

Goto: Art/shapes/actors/gideon/gideon.cs

Change:
sequence4 = "./player_lookde.dsq look";
 
 sequence20 = "./player_looksn.dsq looksn";
 sequence21 = "./player_lookms.dsq lookms";

To:
//sequence4 = "./player_lookde.dsq look";
 
//sequence20 = "./player_looksn.dsq looksn";
//sequence21 = "./player_lookms.dsq lookms";

this removes all gideons look up and down abilities.

Next goto: art/datablocks/weapons/rocketlauncher.cs

scroll down to:

datablock ShapeBaseImageData(RocketLauncherImage)
offset = "0.0 0.15 0.025";
   eyeOffset = "0.25 0.6 -0.4"; // 0.25=right/left 0.5=forward/backward, -0.5=up/down

Change to:
offset = "0 0 0";
eyeOffset = "0 0 0";

(Optional)
While still in RocketLauncher.cs goto:
datablock ProjectileData(RocketLauncherProjectile)

Change:

muzzleVelocity = 100;

To:

muzzleVelocity = 10;

This just makes the projectile stay on screen for longer, more preffrerable for these types of games

(Test! Notice now when you fire your projectiles will go in the direction Gideon is facing rather blowing yourself up.)

3. Fixing the First Person View

By now you've noticed that in first person view you're staring straight into the ground, you cannot change that with the binary copy of Torque 3D (As far as I know) however there is a "work-around". For this work around to work you must create a new character. I shall also supply an example:

torque.abigholeintheweb.com/public_system/useruploads/TopDown_CharExample.zip
(Special thanks to eb for the public hosting system)

3DS Max 2010 file plus DAE ready character for testing purposes.

Example of node placement:
torque.abigholeintheweb.com/public_system/useruploads/TopDown_CharExample.png
Eye = First Person View (Placed way above the character as a top down view)
Cam = Third Person View (Placed infront of the character to see ahead more)
Mount0 = Weapon mount position
Unlink = The parent of Eye and Cam to stop animation moving them

Now by the image above you may have noticed that I've got the Eye Node/bone/dummy way above the player, this will act as a "zoomed" version of the top Down view. This in turn gives the player 2 view options, a zoomed closer view of the player from above and by press tab a further zoomed out view. Not intentionally a feature but this is a nice compromise. Note on the Cam node I have mine out front of the player and above allowing the player to see more in front rather then a centred player in the middle of the screen.

3-A: Using the supplied Character
To use my test character extract worker.dae and orange.png to: art/shapes/actors/worker/ (Create the worker folder)

Then navigate to:
art/datablocks/player.cs

scroll down to:
datablock PlayerData(DefaultPlayerData)

Then change:
shapeFile = "art/shapes/actors/Gideon/gideon.dts";
to:
shapeFile = "art/shapes/actors/worker/worker.dae";

(Test! You should now spawn as an orange player with a top down view by default, hit tab to switch to the zoomed out view)

3-B: Using the your own Character
Create a character as usual and then place the Eye node/dummy/bone way above the character as show above. When animating your character you do not need to add the look up/down animations as they are not used in this resource.

Then navigate to:
art/datablocks/player.cs

scroll down to:
datablock PlayerData(DefaultPlayerData)

Then change:
shapeFile = "art/shapes/actors/Gideon/gideon.dts";
to:
shapeFile = "art/shapes/actors/NAMEHERE/NAMEHERE.dae";

(Test! You should now spawn as your character with a top down view by default, hit tab to switch to the zoomed out view)

And you're done!

Known Issues:
When the player dies the camera goes into free mode allowing the player to look around their body.
On Multiplayer games the player name appears next to the eye node way above the player (Only viewable in third person view).

Side Notes: You can change the visibleDistance in the mission file from 1000 to around 10-40 depending on your camera distance from your players. Remember to designed your 3D environment to be 2D friendly. I plan to expand on this resource in the future, e.g. moving the cross-hire to a more suitable position, source edits that allows the cross-hire in third person view and disabling the first person view entirely.
----

This is my first resource any problems, errors, improvements or presentation suggestions please post them! I'd also like to point out that I'm not a scriptor so easy on the technical talk.

#1
01/30/2011 (8:47 am)
This looks good glen. I`ll give this a try and let you know how it goes!
It would be interesting to see if I can get this changeable from script, so I could change it mid game. Like when I get into a my robot. Lol!
#2
01/31/2011 (8:34 am)
Thumbs up. Good resource.
#3
01/31/2011 (10:24 am)
Looks good. However, would it be hard to parent the camera to the player's position instead of the player's eye node?

This would allow support for every model without changing the position of the eye node.
#4
02/05/2011 (12:45 am)
Nice...