PDA

View Full Version : first person shooter - tips needed



dodgyposse
10-15-2002, 07:25 AM
Hi,
I am coding a fps game, and have encountered a problem.

I am setting the camera to look at the centre of my players position. The camera is positioned on the limits of the players bounding sphere.

I am using the bounding sphere, to ensure the player doesn't pass through the walls BUT, when I rotate the camera, I am suddenly clipping into the walls, at the left and right edges of the screen.
i.e I can see right into the next room.

I have tried a few things, including shortening the cameras distance from the centre of the bounding sphere, and that didn't work.

I tried throwing out rays at 90 degrees to the left and right of the camera direction, and detecting when these rays hit solids,and that helps a bit...but doesn't solve the problem entirely.

In this situation I also tried pushing the camera back a little way, but it means the player can't get flush with a wall...

Someone out there must have done this before...can you offer any tips please!!!!??

dd

dawn
10-15-2002, 07:42 AM
You must also test the camera against the walls i.e. create for it a small bounding sphere and do the same things as for the player. And afterwards you can keep the distance to the player but modify the looking angles (as a moving on a player's surrounding sphere) - look at tomb raider (the game a mean http://www.opengl.org/discussion_boards/ubb/smile.gif, not at angelina).

[This message has been edited by dawn (edited 10-15-2002).]

JML
10-15-2002, 09:55 PM
dd,

I think you have to make sure that the near-side of the frustum is inside the bounding sphere of the character. That should prevent clipping of walls against the near plane as long as the walls are kept outside the bounding sphere.

HTH

Jean-Marc.

dodgyposse
10-15-2002, 10:53 PM
Ok,
I was using the players bounding sphere to determine the position of the camera.

Basically, the camera floats about the surface of the players bounding sphere.

Imagine you are in a room with lots of square columns. As you approach the columns,
everything looks ok...you rotate, and suddenly you can see inside the columns.

No matter what I do with the camera, there seems to always be a scenario where I can see inside my scenary.

The game was to be 3rd person only ( thats works nicely now!), and to be honest, fps is nice, but I'm sorely tempted to ditch it....it's more hassle than it's worth http://www.opengl.org/discussion_boards/ubb/wink.gif

Thanks for the advice everyone.

dd

JML
10-15-2002, 11:38 PM
Originally posted by dodgyposse:

Basically, the camera floats about the surface of the players bounding sphere.

Imagine you are in a room with lots of square columns. As you approach the columns,
everything looks ok...you rotate, and suddenly you can see inside the columns.

dd,

Is your camera 'looking through' the bounding sphere (i.e. when looking forward: is the camera at the back of the bounding sphere?)?
If not, then sure, you will get near-plane clipping as the near plane is outside the bounding sphere.
If it is on the opposite side then 'all' you have to do is make sure the near rectangle of the viewing-frustum is always completely inside the sphere.

HTH

Jean-Marc

dodgyposse
10-16-2002, 01:30 AM
Yes, my camera is at the rear of the bounding sphere, looking through the centre of it...

dd

Tom Nuydens
10-16-2002, 04:14 AM
I really don't follow this. If you're using a first-person view, then how can your camera look at the center of the player's bounding sphere? Are you saying that if you look straight up, the camera drops to the bottom of the sphere (i.e. to the ground)?

If so, you have a strange definition of "first person" -- I always thought it meant looking at the world through the eyes of the character. I don't know about you, but my eyes don't move around on the surface of my bounding sphere -- they stay in my head http://www.opengl.org/discussion_boards/ubb/smile.gif

-- Tom

dodgyposse
10-16-2002, 04:20 AM
As I mentioned, I tried placing the camera at the centre of the players bounding sphere, and looking forward to a point on the bounding sphere.....and that didn't work.

And then I thought...ok move the camera viewpoint and destination back ...so I positioned the camera behind the player, looking at the centre of the sphere....
and that didn't work...

What ***DID*** work, was bringing my near clipping plane to be 0.01 instead of 1.0.

Bingo!! it works a treat now.

Thanks for prompting me to investigate clipping planes.

Tom Nuydens
10-16-2002, 04:27 AM
Ah, ok. By the way, you might want to place the camera near the top of the sphere, rather than in the center. Having eyes in your groin isn't very realistic http://www.opengl.org/discussion_boards/ubb/wink.gif

-- Tom

dodgyposse
10-16-2002, 04:28 AM
Thanks Tom! Wondered why i was so low to the ground! http://www.opengl.org/discussion_boards/ubb/wink.gif