Physic-Chasing Camera

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
lareusoular
Posts: 40
Joined: Mon Sep 06, 2010 9:22 pm

Physic-Chasing Camera

Post by lareusoular »

I saw the another topic, so I got a question.
In Mass Effect, a Third-Person Shooter, When I get too close to a wall, the camera gets closer to Sheppard(the player). This is why if it got outside the wall there was going to be a nice-horrible drawing(see the outside of the wall, with the normals inverted would give a horrible image =(

Is there a way to use BEPU to make something like that? My PhysicCameras here are all FirstPerson =(... How can I do that, is that a easy way?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Physic-Chasing Camera

Post by Norbo »

The vehicle chase camera in the BEPUphysics demos uses a chase camera. You can check it out for an example.

Basically, it just raycasts back from the character eyes to the 'desired' camera location. If it hits something, the camera is pulled forward so that it's in front of the obstacle.

You might find that using a 'fat' ray can make things a little nicer, too. That way, the camera will move forward a little earlier to prevent your screen from being obscured halfway by the wall first. A good way to do this would be a spherical cast against the environment- the engine has some swept tests you could use for this.

Be careful what you actually test for camera occlusion, as well. Sometimes the collision shape doesn't match the visible geometry or isn't associated with visible geometry, and you'll have to make choices about how to handle those cases.
Post Reply