3rd person camera help

Posted By: MrNoOne

3rd person camera help - 01/30/10 14:55

I'm working on a 3rd person camera on my game, I have most of it done, but I need help with the tilt. I want my camera to tilt around the player when looking up or down. At the moment when I look down it just looks down from where the camera is, which I do not want. I searched around for this, but I did not find anything. Please help. Thanks.
Posted By: davinski

Re: 3rd person camera help - 01/30/10 15:15

We cant help you without seeing the code.
Please post it!
Posted By: MrNoOne

Re: 3rd person camera help - 01/30/10 15:39

this is the code:

function handle_camera()
{

camera.x = my.x - fcos(my.pan, 120);
camera.y = my.y - fsin(my.pan, 120);
camera.z = my.z + 30;

camera.pan = my.pan;
camera.tilt += (mouse_force.y*5);
//////
//////
if(camera.tilt > 90)
{
camera.tilt = 90;
}
else if (camera.tilt < -90)
{
camera.tilt = -90;
}

}

Posted By: Tobias

Re: 3rd person camera help - 01/30/10 19:04

You must do the same thing as for the pan, move the camera up and down when tilting down and up, try this:

camera.z = my.z + 30 - 120*sin(camera.tilt);

Havent tried it myself but thats the general idea.
Posted By: Widi

Re: 3rd person camera help - 01/30/10 19:32

...and something for the code, replace:

if(camera.tilt > 90)
{
camera.tilt = 90;
}
else if (camera.tilt < -90)
{
camera.tilt = -90;
}

with:

clamp (camera.tilt,90,-90);
Posted By: MrNoOne

Re: 3rd person camera help - 01/30/10 20:00

The clamp does not work for me which is why I have the other code.
Posted By: Tobias

Re: 3rd person camera help - 01/31/10 14:55

I think the correct way is camera.tilt = clamp(camera.tilt,90,-90);

At least its this way described in the manual.
© 2024 lite-C Forums