Third Person Camera System

Posted By: Locoweed

Third Person Camera System - 08/30/05 03:48

Hi,

I was told I better show this camera system when I got it working ok.

So here it is.

I still have never found a good way to keep the camera out of the walls other than by keeping the player a certain distance from the wall, which is what is done in this example. How I did it with this example was to create and invisble cylinder around the player that actually does the player movement, keepng the player a certain distance from the wall. There are other possible ways to do this, but this is probably the simpliest so that's what I did here. This example uses c_move, c_trace, etc.

I put 2 camera modes in the example so you get an idea of how to use the system. Hit F7 to change modes.

CAM_MODE_CHASE
The game starts in this mode. In this mode, you use the mouse to rotate the player and to change the camera tilt. Pressing the 'Q' key will force the camera to the front.

CAM_MODE_THIRD
In this mode, you use the A, D, or cursor keys to rotate the player. The mouse changes tilt and if you are not moving forward the mouse can also be used to rotate the camera around the player in a free style.

You can add whatever modes you like or add things to the existing modes. I put alot of extra camera movement functions in the code too, that currently aren't being used, but can be easily added into the camera mode functions, i.e., MoveCamLeft(), MoveCamRight().

An example of adding these to a mode would be changing CameraChase() to this:

function CameraChase()
{
// get angle diffrence between player pan and camera pan
CamPlayerAngDiff = ang(player.pan-camAng.pan);

if(key_q)
{
cameraRotationMode = ROTATION_MODE_SLOW;
MoveCamFront();
}
else
{
if(key_z)
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamLeft();
}
else
{
if(key_c)
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamRight();
}
else
{
cameraRotationMode = ROTATION_MODE_MEDIUM;
MoveCamBehind();
}
}

I just added keys Z and C to move camera off to left or right of player in that code.

There is some stuff that effects the camera that is in the PlayerEnt action, make sure you notice those if you are trying to add the camera system to your existing player action code.



It's at my 3DGS site, which is listed in my signature below. It's in the Camera link at my site.

Posted By: Orange Brat

Re: Third Person Camera System - 08/30/05 03:51

Yeah, I tested this and in the test level, the camera only clipped when inside a doorway. I don't know if that's been tweaked, but I can say this is the best wall collision I've seen. This is the Holy Grail, or at least it was in that test 99.9% of the time.
Posted By: DCorwin

Re: Third Person Camera System - 08/30/05 20:07

This is the nicest camera implementation I've seen in GS! Good job!

How come the cyberbabe eats the soldiers when she walks into them though? :-)
Posted By: bupaje

Re: Third Person Camera System - 08/30/05 20:48

Very cool camera contribution -thanks!
Posted By: Locoweed

Re: Third Person Camera System - 08/30/05 22:41

Quote:

How come the cyberbabe eats the soldiers when she walks into them though? :-)




I dunno, maybe she's a man-eater. I think that was a song back in the 80's.

Just comment out these 2 lines of code in Enemy action and she will be more politically correct.

my.enable_impact = on;
my.event = EnemyEvent;

Loco
Posted By: Nadester

Re: Third Person Camera System - 08/31/05 02:36

Very nice. I was damn sure I remember editing your post
Posted By: Locoweed

Re: Third Person Camera System - 08/31/05 03:37

@ Nadester
Lol, yeah you called me "goofy" if I remember right, thats why the edit is gone.

For a "very limited" time ( I am busy after all ), anyone who gives me a link to a game demo with a 3rd person camera, I will duplicate it and show you the code with this system if it is possible. Don't give me a link to SH3, I definately won't do that one for you.

But something like Lugaru, no problem (Well, not no problem, but possible). I don't know why I picked that game as an example, but it's camera was a bit unique when I tested it. Almost looks like it was made with 3DGS actually.

Loco
Posted By: bupaje

Re: Third Person Camera System - 08/31/05 04:39

errrr ... ZooTycoon2 (just happened to download the demo to show my kids and nieces ....). Overhead 'Builder' cam and has option to hold key and rotate the viewscreen, or player view and also to drop down and view the zoo as a visitor (or the guy who cleans up the poop -why my kids thought was funny ) Probably something like what yours does now.
Posted By: nuclear_winter

Re: Third Person Camera System - 08/31/05 07:19

Great job Loco!!!
Can you make the camera to delay a little, i mean character model to turn a little before the camera, as if the camera follows her... and for the FOV to increase when she picks up speed and softly decrease when she stops. Just some ideas here, if I'm out of my element and don't know what the hell I'm saying, I'm sorry!

For your camera offer, can you try a Crash Bandicoot camera? The main one that is "on a rail" behind the character and goes higher pointing down or lower pointing forward depending on the occasion (stairs, slopes, etc), then goes a little farther form him when he runs faster, revealing a bigger portion of the level. The camera also follows Crash to the sides while staying attached to the "rail" but does not keep him centered while jumping, making it possible for the character to disappear form view if the jump is too high . There are other levels which are sidescrollers, nothing special about the camera there (keeping the side view with the character centred in the middle), and there are the vehicle levels with a little more complex camera (delays after the vehicle turn to give the impression of sliding sideways).

Great job man, keep it up!
Posted By: bupaje

Re: Third Person Camera System - 08/31/05 17:16

Maybe a useless post since it's not what you asked for but as I was reading here I wondered if a 'helium balloon with a rubber band' effect might be nice. The camera would float over the player, looking down at him, when he runs / walks depending on the speed the camera floats down to be a chase cam. When he stops it floats back to its overhead position. The 'rubberband' part would be the distance of the cam from player as he runs faster the camera distance stretches. When he stops it snaps back to original distance and of course slowly floats back to its overhead position.
Posted By: DCorwin

Re: Third Person Camera System - 08/31/05 23:33

I think an overall nice feature that the game dev studs are doing these days is adding a nice inertia to the camera system.
Posted By: Locoweed

Re: Third Person Camera System - 09/01/05 02:51

Quote:

Can you make the camera to delay a little, i mean character model to turn a little before the camera, as if the camera follows her... and for the FOV to increase when she picks up speed and softly decrease when she stops.




Yes and yes. I think the camera already does the second thing mentioned, unless I misunderstood you. As to the first question, yes I can make the player turn and the camera turn a bit slower, it's just a matter of adjusting a variable or two in the code.

EDIT:
@ nuclear_winter, change this in InitCamera(), camRotSpeed = .75; to this camRotSpeed = .25; , that should delay the camera as per your first question.
EDIT2: Oops, I tied camera tilt into camRotSpeed, I will have to adjust this before it works correctly. I will have to add a camTiltSpeed variable to seperate rotation speed from tilt speed. I will get these little issues fixed, hopefully tommorrow night. I actually already have it changed, but I want to play around with changing the values some more to make sure I don't have any more issues like that one and probably add some more adjustment variables before I re-upload it.

As far as inertia goes, I can make that more evident than what was shown in the examples by adjusting some variables in the GetCameraAccelleration() function.

Messing with the values of these 2 variables in InitCamera() function will change the feel of the camera quite a bit:

camRotSpeed = .75; // how fast the camera pan changes
camMoveSpeed = .1; // how fast the camera distance changes

The lower the values you change them too, the slower that camera will get behind the player and move to where it wants to be. If you make the values higher, the camera will basically stay right behind the player with no delays.

I will check out the listed cams when I get time. It finally dried up and I am harvesting crops again.

Loco
Posted By: Nadester

Re: Third Person Camera System - 09/01/05 04:11

The Hobbit Demo

Mimic a camera as stable as that, and let the player turn around (like a mario/zelda cam), and I'll be your best friend
Posted By: SlyBoots

Re: Third Person Camera System - 09/01/05 04:20

Sounds promising, can't wait to try it out.
Posted By: nuclear_winter

Re: Third Person Camera System - 09/01/05 12:15

Thanx for the suggestion bupaje, i had something like that in mind, i remember some time back someone made a demo like that. The camera moved on some kind of rail (waypoints) and decreased/increased speed depending on the distance to the player, but i don't remember exactly.

LOCO, thanx for the tips man, changing camRotSpeed = .75; did a great job. By FOV i meant camera.arc (increase when she picks up speed and softly decrease when she stops). Thanx!!
Posted By: Locoweed

Re: Third Person Camera System - 09/02/05 02:59

Ok nuclear_winter,

I gotcha now. I will add that FOV capabilty. It am busy with real life, so it will probably be Sunday night sometime before I put up the next update. If I have time I will throw a few more camera examples in there also.

Loco
Posted By: nuclear_winter

Re: Third Person Camera System - 09/02/05 08:13

That's cool man!! It's a good contribution, do it whenever you have the time and desire
Posted By: Locoweed

Re: Third Person Camera System - 09/03/05 04:07

Sorry guys on the listed cameras for games that I will have to download, it might be a few days before I can get to those. I am not going to have anytime off this weekend like I thought.

I did upload a new version that is more flexible though. I just threw it together real fast and it has a few new examples.

There are 5 camera examples now, you can change to the different camera modes using the number keys.
Key:
1 - Chase Camera
2 - Third Camera
3 - Balloon Camera
4 - Fov Cam 1
5 - Fov Cam 2

By looking at all the InitCam and the camera functions for each camera type, you should be able to start figuring out which variables do what and how it works.

I will get to some of the actual listed game cameras when I get time. I will also get it tweaked out better and documented better to when I have time.

The new update is at the same place, at my 3dgs site in camera link, LocoCam.

Later,
Loco
Posted By: Jamie_Lynn

Re: Third Person Camera System - 09/03/05 04:53

Thanks for another nice contribution Loco.

Works great! Thanks.
Posted By: AppollyonKin

Re: Third Person Camera System - 09/05/05 12:48

I just tried to upload the camera zip from your site, and it is a bad file, and only downloads 124kb instead of 1 meg. can someone email me the file? at triath5147@msn.com.
Posted By: Locoweed

Re: Third Person Camera System - 09/06/05 02:34

It's been re-uploaded now and should be ok. Thanks for letting me know it was corrupted.

Loco
Posted By: Jamie_Lynn

Re: Third Person Camera System - 09/06/05 04:30

Actually Loco...I had trouble downloading the last version as well. It eventually downloaded but it seemed like your site kept dropping the link. It took about five attempts to get the download to complete...but once it actually completed the zip wasn't corrupted. Not sure what that means.
Posted By: Olzii

Re: Third Person Camera System - 09/06/05 06:52

Hi Loco,

Please convert your tutorial for a car game ? / Replacing player MDL and doing some steering adjustments /

Olzii
Posted By: nuclear_winter

Re: Third Person Camera System - 09/06/05 07:29

Quote:

Hi Loco,

Please convert your tutorial for a car game ? / Replacing player MDL and doing some steering adjustments /

Olzii



That would be almost too nice... using the turning delay and the FOV change, but maybe were asking too much. Only el Loco will say.
Posted By: William

Re: Third Person Camera System - 09/07/05 05:27

From the site:
"This Account Has Been Suspended
Please contact the billing/support department as soon as possible."

Mabye you've seen this already.

Hope you get everything figured out soon as I really would like to test this camera script.
Posted By: Locoweed

Re: Third Person Camera System - 09/09/05 00:47

Yeah, trying to figure out what happened. I sent the check over 2 weeks ago. It is down in Florida somewhere, maybe the hurricane slowed the mail there, I dunno. I will let you know when the site is back up.
Posted By: william_123

Re: Third Person Camera System - 09/09/05 05:45

Hi Loc.
Your Third Person Camera System is very useful.
I go through your Camera system.
But I have a problem about how do I add 1st person Camera System like this




Thanks for any advance.
And thanks already
Posted By: Locoweed

Re: Third Person Camera System - 09/13/05 21:07

Sigh, My 3DGS site should be back up now.

@ william_123, I will consider adding a first person cam to it.

Loco
Posted By: muralist

Re: Third Person Camera System - 09/23/05 22:23

[quote
For a "very limited" time ( I am busy after all ), anyone who gives me a link to a game demo with a 3rd person camera, I will duplicate it and show you the code with this system if it is possible. Don't give me a link to SH3, I definately won't do that one for you.

Loco




Aha! here's a link to Ground Control -- the full version (free) witha great camera system. Can you code this in 3dgs?

http://www.fileplanet.com/142438/140000/fileinfo/Ground-Control-Full-Game-w/-GC2-Multiplayer-Demo
Posted By: Locoweed

Re: Third Person Camera System - 09/23/05 22:55

I will look at it muralist when the fileplanet servers are free. As for past post on this, like The Hobbit, I will check those out too. Sigh, nothing worse than reinstalling windows and loosing all those usernames and passwords.

EDIT: I am downloading The Hobiit now. I will check that camera out first.
Posted By: muralist

Re: Third Person Camera System - 09/23/05 23:15

Thank you Sir.
Posted By: AppollyonKin

Re: Third Person Camera System - 10/22/05 17:13

This may be a dumb question but I am not a great scripter. So to add this to my own animaiton codes, I would just have to tac the "if camera max dist, else cam max dist" lines to the end of my animation lines correct?
Posted By: broozar

Re: Third Person Camera System - 10/22/05 19:45

wonderful, just what i need. by any chance, could you implement a zoom when turning the mouse wheel?
Posted By: Lion_Ts

Re: Third Person Camera System - 10/22/05 20:13

Code:

...
var mouse_wheel = 0;
mouse_wheel = sys_metrics(75); // see if the mouse has a scrolling wheel or not
while (1)
{
if (mouse_wheel != 0) // wheel present?
{
// then use the wheel to zoom in and out
camera.arc -= 0.1 * mickey.z * time;
}
else // wheel not detected
{
// use the "Y" and "H" keys to zoom in and out
camera.arc -= (key_y - key_h) * time;
}
camera.arc = clamp(camera.arc,20,90); // limit camera.arc to 20..90 degrees
wait (1);
}
...


Posted By: broozar

Re: Third Person Camera System - 10/22/05 21:17

thx, but where to put it? it produces errors everywhere i try...

[EDIT] thx, found it out by myself

[EDIT2] works great, though it does not do exactly what i wanted.
you cahnged the camera arc, so it appears to be a zoom function. thatīs what i wrote, right, but i meant something different.
i do not want the arc changed. i want the camera to come closer to the player/go back without changing the FoV.

damn, my english really needs some revision, i cannot express my thoughts...
Posted By: AppollyonKin

Re: Third Person Camera System - 10/24/05 16:51

Just replace cam.arc, with camMaxDistStand adn that should move the camera closer to the player if thats what u mean.
Posted By: broozar

Re: Third Person Camera System - 10/27/05 19:19

thatīs it, many thanks to all you coders out there!!
Posted By: Kotakide

Re: Third Person Camera System - 02/14/06 07:08

nice camera contribution
© 2024 lite-C Forums