Game Development Community

A new camera/control system

by Jon Law · in Torque Game Engine · 01/18/2006 (10:09 pm) · 3 replies

Hi! I have been developing a game for the past few weeks and finally decided that I would need a new camera system. I browsed through the resources but only found advanced camera and a few other, slightly less feature heavy, resources. Don't get me wrong this is a GREAT resource but it has problems when trying to control the character in third person, amongst other problems. What I am looking for is a system with the following features

*Able to switch between first and third person modes

*Has different third person modes (similar to advanced camera. Mainly used for fighting a boss, where the boss should always been in sight...ie keep two things in frame, player and boss.)

*Can dynamicly switch between camera modes mid game (change for cinematic sequences, boss fights, to point out somthing etc)

*When in first person aiming is the same as it is in the HEAD

*Movement is as follows.. a=TURN left d=TURN right q=straf left e=straf right w=forwards s=backwards (think world of warcraft)

*When in third person aiming is as follows.. moving the mouse will change x y coordinates of the crosshair (sort of like a selection cursor, but instead controls where the shot will be fired), when fired a ray is cast from the 2d crosshair to the 3d surface, unlike the resource "super crosshair" (ray is cast from muzzle and crosshair is set to where ray lands... so its the opposite)..

Does this sound at all possible? I was wondering if someone would like to collaborate with me on this to create a really wonderous resource that im sure the community would enjoy. I have limited skills in c++ but i know my way around. Please feel free to drop me an e-mail or if you have any ideas/comments/whatever pleeeeeese post
thanks
~jon

#1
01/19/2006 (5:00 am)
All you need is to do some modifications to the AdvancedCamera. Even if none of the modes work exactly like you want, it isn't very hard to modify them to do so, and it's easy to add new modes too. As example, we added a "DialogMode" to our source tree that we use in cutscenes when a character is talking to another one. It focus both characters on the screen and angles itself so the talking character's face is visible, and the listener is facing back. It saved us the trouble of hand-placing cameras in 95% of the cutscenes.

For cinematics: pathCamera. Create one when your game starts, and switch to it when you need to.

The default TGE character control is already as you described: you can turn left/right and strafe left/right in character-space.

Aiming in 3rd person is already possible without any kind of modification, all you need is to switch the actionMap.

For shooting at something below a crosshair, you have two options. Either you draw the crosshair where the character is truly aiming at, or you draw it where you want it to be and do a raycast to find out what's beneath it. For both alternatives you'll need to expose the GameTSCtrl::project() and GameTSCtrl::unproject() methods to console. The first one allows you to convert a point from world space to screen space, and the other will do the reverse. Using two unproject calls you can easily find a start and end position for your raycast. I've used it in a mini-game in a recent project, to hit objects below a moving crosshair and it works like a charm.
#2
01/19/2006 (5:13 pm)
Hehe.. well thats a lot easier said than done. can you offer any advice for the process or any snags you ran into, in your experience. also if anyone has any other ideas please post em here
#3
01/20/2006 (4:53 am)
The main caveats is learning where to put your new code. Basically, learning about the basic TGE flow, which functions are called on the client, on the server and both, and which are called at every frame and at every tick.

When you learn how to create console methods, add new class members, properly send them from the server to the client, and use them in client and server updates, you'll have no problems in changing the behavior of most classes from simObject down (and after some time, you can start changing things below that too).