GameCamera: a third person, aiming camera (that works!)
by Michael Bacon · in Torque Game Engine · 09/13/2007 (6:44 am) · 81 replies
Update: I have fixed the jitter and the issues I had with the network code. I think everything is working as it should be.
Well, I've been working on a new third person camera. I wanted the player to aim where my third person camera is looking.
This has been sought after by quite a few people including myself. I didn't find what I was looking for elsewhere so here is my attempt.
I've got the basics working. This camera was built on a HUGELY modified Advanced Camera but has pretty much grown into its own being. It is now called the GameCamera.
Features:
Third person camera
Player fires where camera is looking
The server controls where the camera should be
Caveats:
No server side interpolation is done (for instance if you switch targets the client side will interpolate the difference in like one tick but the server will have already been there. I hope to add this later.
Download here and add gameCamera.cc and gameCamera.h to your project in under the engine\game folder.
Video here shows the camera in action while fighting a bot.
------------------------------------------------
If you follow all the directions here (especially the one about setting the 'correctMuzzleVector = true' value on your weapon datablock) you will have a third person camera and a player that fires at the center of your screen.
------------------------------------------------
In order to implement the camera you need to make a few changes...
Well, I've been working on a new third person camera. I wanted the player to aim where my third person camera is looking.
This has been sought after by quite a few people including myself. I didn't find what I was looking for elsewhere so here is my attempt.
I've got the basics working. This camera was built on a HUGELY modified Advanced Camera but has pretty much grown into its own being. It is now called the GameCamera.
Features:
Third person camera
Player fires where camera is looking
The server controls where the camera should be
Caveats:
No server side interpolation is done (for instance if you switch targets the client side will interpolate the difference in like one tick but the server will have already been there. I hope to add this later.
Download here and add gameCamera.cc and gameCamera.h to your project in under the engine\game folder.
Video here shows the camera in action while fighting a bot.
------------------------------------------------
If you follow all the directions here (especially the one about setting the 'correctMuzzleVector = true' value on your weapon datablock) you will have a third person camera and a player that fires at the center of your screen.
------------------------------------------------
In order to implement the camera you need to make a few changes...
#62
10/29/2007 (12:21 am)
The Zip-File is now not avaliable.
#63
10/29/2007 (3:41 am)
Sorry about that, issue resolved. I was in a hurry I must not have uploaded the file....
#64
10/29/2007 (7:26 am)
Great resource! I was able to implement this to a clean install of 1.5.2 and it worked first the first time! There are a few things that I'd like to handle differently (and will attempt after I back this version up), but I'm really stoked about how nicely this dropped in. Thanks a ton Brian!
#65
I'm really intersted in what you plan on changing. I still have more I'd like to do with this but I'd be very happy to discuss possibilities and improvements with others.
10/29/2007 (7:36 am)
It took the work of several people here in order for me to get this to that point.I'm really intersted in what you plan on changing. I still have more I'd like to do with this but I'd be very happy to discuss possibilities and improvements with others.
#66
The first thing I was considering trying was the ability to zoom in and out in 3rd person using the mousewheel (or a keybind).
Next, what I was working with before (and was unable to implement) was the combined resource for selecting objects and several other functions. Selecting with the camera free looking would be quite difficult, so the larger task at hand would be turning gameCamera into one where the position is fixed and then adjusted by a mouse drag.
Ideally, that would be something that could be toggled, or is a separate implementation all together as the current version of gameCamera works really well (IMO) for a PVP or PVE action setting. It feels really good, my only desired tweak being the zoom I mentioned.
As a tangent, I know that orbitCam from the Advanced Camera is close to what I've described, but 1) as I mentioned, I couldn't get it to work and 2) when the camera is zoomed in I don't like the way it feels because of the camera being on a sphere - you wind up looking at the ground.
Edit: removed off-topic comments
10/29/2007 (8:44 am)
Good point, Brian, I've read through a lot of threads with camera work from those folks as well as yourself, and shouldn't have omitted the "& others" from my thanks! So, thanks to *everyone*! =)The first thing I was considering trying was the ability to zoom in and out in 3rd person using the mousewheel (or a keybind).
Next, what I was working with before (and was unable to implement) was the combined resource for selecting objects and several other functions. Selecting with the camera free looking would be quite difficult, so the larger task at hand would be turning gameCamera into one where the position is fixed and then adjusted by a mouse drag.
Ideally, that would be something that could be toggled, or is a separate implementation all together as the current version of gameCamera works really well (IMO) for a PVP or PVE action setting. It feels really good, my only desired tweak being the zoom I mentioned.
As a tangent, I know that orbitCam from the Advanced Camera is close to what I've described, but 1) as I mentioned, I couldn't get it to work and 2) when the camera is zoomed in I don't like the way it feels because of the camera being on a sphere - you wind up looking at the ground.
Edit: removed off-topic comments
#67
11/12/2007 (11:25 pm)
Some news about collision issue here?
#68
This doesn't mean it won't happen. I just have some other things that need to get done first.
I guess its useful to note that I'm giving the GameCamera an overhaul (again). I've fully implemented an Orbit mode camera and am going to add easily selectable modes. Not sure how yet.
11/13/2007 (12:27 am)
I have been too busy to try implementing a better collision scheme lately. Currently the project doesn't need better collision than this though I would certainly like it.This doesn't mean it won't happen. I just have some other things that need to get done first.
I guess its useful to note that I'm giving the GameCamera an overhaul (again). I've fully implemented an Orbit mode camera and am going to add easily selectable modes. Not sure how yet.
#69
in gameCamera.cpp
remove
and change GameCamera::renderImage(SceneState*, SceneRenderImage*) to:
Again, feel free to correct...
11/21/2007 (4:54 am)
After a bit of tweaking I have this working just fine in TGEA (from my initial testing). The changes were very small and simple (although it was the first time I've done a TGE OpenGL -> TGEA DirectX conversion so feel free to correct this):in gameCamera.cpp
remove
#include "dgl/dgl.h"
and change GameCamera::renderImage(SceneState*, SceneRenderImage*) to:
void GameCamera::renderImage(SceneState*, SceneRenderImage*)
{
if(gEditingMission)
{
GFX->pushWorldMatrix();
GFX->multWorld(mObjToWorld);
wireCube(Point3F(1, 1, 1),Point3F(0,0,0));
GFX->popWorldMatrix();
}
}Again, feel free to correct...
#70
01/18/2008 (2:40 pm)
I've gotten this in, no compile or runtime errors, but the camera won't act like a camera (let me view from it), I can't control the camera, I can't look up or down, and (this is actually good news) when I fire my gun the shot goes off at a funky angle. Any suggestions?
#71
Are there any complaints when you try to set the camera object on the connection?
Have you made the required changes in ShapeImage.cc and GameProcess.cc?
What is the datablock you are using for the camera?
I'll try to help as much as I can but pretty much if you follow the directions to a T, it should work.
01/19/2008 (3:14 am)
So... when you create the camera, does it give any errors?Are there any complaints when you try to set the camera object on the connection?
Have you made the required changes in ShapeImage.cc and GameProcess.cc?
What is the datablock you are using for the camera?
I'll try to help as much as I can but pretty much if you follow the directions to a T, it should work.
#72
Thank you, Eikon Games too for your posting. :-)
01/19/2008 (4:50 am)
Nice job, what I want to port to TEGA.Thank you, Eikon Games too for your posting. :-)
#73
I successfully integrated this with GuiAnimatedCrosshairHud on TGEA 1.0.3.
It works fine.
Thank you for your efforts. :-)
01/20/2008 (8:07 pm)
Great!I successfully integrated this with GuiAnimatedCrosshairHud on TGEA 1.0.3.
It works fine.
Thank you for your efforts. :-)
#74
10/22/2008 (12:42 am)
Anyone have any pointers on intergrating this into 1.7.1?
#75
05/15/2009 (4:01 am)
its a great resource, i have to say thanks to you for giving this excellent resource.i tried to implement this resource in TGEA1.8.1 its working properly. i have one problem. i.e. the weapon is moving along with the mouse movement. i want to move the cross Hair along with the mouse movement instead of the weapon , so that the player can knows the aiming location??? can you help me ... thanks in Advance.
#76
05/29/2009 (4:59 am)
deleted
#77
07/04/2009 (2:53 am)
hi.. it is a very good resource. i implemented this resource, everything is working fine. but i got one problem that is my camera is jittering. how to fix it can anyone of you expalin me??? plzzz
#78
12/21/2010 (7:01 pm)
Link is broken, source is dead... where from can I download this archive?
#79
12/21/2010 (7:50 pm)
Now I don't need these files because I have solved this problem
#80
Thank you.
10/03/2011 (12:03 pm)
Download link is dead. Anybody has a copy that would like to share?Thank you.
Torque Owner Michael Bacon
Default Studio Name