Sign in to follow this  
ehmdjii

camera collision detection

Recommended Posts

hello, i have a camera that always looks at the main character from a certain distance and can be freely rotated around the character, but always stays at its distance. now since the character should always be visible i want to check if something is between the character and the camera position and then place the camera at the nearest intersection point of the occluder. for starters my datasturcture is very simple. the terrain is a regular grid and only whole tiles should be checked. does anyone know of a simple algorithm to accomplish this? thanks!

Share this post


Link to post
Share on other sites
Simple sphere collision should be good enough: Check collision from the center of the sphere(where the camera is) to the planes: check the distance from the center of the sphere to the closest point on those planes. If that distance is closer than the radius of the sphere, the plane colliding/intersecting the sphere.

Share this post


Link to post
Share on other sites
thanks
ok, but how do i get the planes?

as i said the collision detection so far is based on a regular grid, where each grid cell can be passable or not.

Share this post


Link to post
Share on other sites
extract the triangles from each cells, and do ollision with those. Using raytrace from character's head, or a swept sphere, to find the furthest valid position.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this