Jump to content
  • Advertisement
Sign in to follow this  
pondwater

3rd person camera collision response

This topic is 2442 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i've programmed my camera to follow and rotate around the player as it does in most 3rd person games. Now comes the issue of preventing it from becoming embedded in objects. Here is what im planning and im wondering if anyone with experience could comment.

The 'part' of the camera that will be used in the collision detection is the yellow 'rectangle' or the near panel of the viewing frustrum. I figure that if any part of this rectangle is 'colliding' with an actor or environmental object, the the vision will be obstructed. If this assumption is incorrect, please let me know.

clPzY.png


So heres basically what I figure i will do:

1) do a quick boolean intersection test. Is any part of the near 'yellow' panel embedded in an object. If no, leave the camera as is. I with use my GJK-SAT algorithm for this.

2) if the GJK-SAT returns true, it is intersecting. I could either:

  • A) move the camera to the furthest non-intersecting position from the player
    • B) move the camera to the closest non-intersecting position from the player.

      iHtfv.png


      Im leaning towards option B. I think thats how most game cameras deal with intersections. Either way im doing a swept rectangle test. Except for option B i use the furthest position instead of closest.

      What do you guys think? Would this produce satisfactory results? Is there a more efficient way?

      Thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement

Im leaning towards option B. I think thats how most game cameras deal with intersections. Either way im doing a swept rectangle test. Except for option B i use the furthest position instead of closest.

What do you guys think? Would this produce satisfactory results? Is there a more efficient way?

From what point are you intersecting? I'd start from the player and backup until an intersection occurs, that'd be the nearest intersection. I use a sphere instead of a rectangle, easier to handle for me.

Share this post


Link to post
Share on other sites

From what point are you intersecting? I'd start from the player and backup until an intersection occurs, that'd be the nearest intersection. I use a sphere instead of a rectangle, easier to handle for me.
[/quote]

Okay, that sounds good, im assuming you fit the circle to the rectangle as such:

Ye1De.png
Where the diameter of the circle would be the distance from one top corner of the rectangle to the opposing bottom corner, and centered on the geometric centre of the rectangle?

Also if the player is right up against an obstacle and therefore the camera cannot be placed without being embedded in the player then i would simply not render the character and center the camera on their origin to give a temporary 'first person view'. Most games tend to do that i believe.

Share this post


Link to post
Share on other sites
Yes that's correct. Another option is to temporarily change the camera angle so that the camera goes up, in most games there's hardly any obstacle that prevents the camera from going up. I went with 'first person view' when the camera gets too close because the camera angle is of significant importance when using the mouse, sudden changes would be very annoying to play with.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!