Jump to content
  • Advertisement
Psychopathetica

3rd Person Collision

Recommended Posts

Hello. Basically I ran into an issue where I have a ball a certain distance in front of a FPS movable camera, basically 3rd person. If the ball hits a wall, it detects the collision, but rather than enacting the collision response, it ends up going through it! Mainly because the object wants to continue being that distance in front of the camera. And my collision code is so precise that no matter how fast the object goes, itll hit the wall no matter what, which is strange.

However, if I just let the ball freely move and hit the wall, the ball collides and does the collision response as it should. I tried looking up 3rd person collisions on Google, but all the articles unfortunately were involving the camera, not the object in front of the camera. Basically the effect Im looking for is if the object in front of you hits the wall, then not only should the object stop and sweep along it, but the camera as well. What can I do to achieve this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement

First: sphere object collision and camera collision - in most cases is the same sphere collision ..

You say it hits the wall no matter what so here are 2 solutions

- no it doesn't

- you do not attach collision response

Share this post


Link to post
Share on other sites

The way I did this was make the camera a follow camera. So you are really moving the ball (in my case a character).  All the camera does is obey the "follow camera" rules that it's programmed with. 

You also need some collision for the camera but this would be a different kind of collisions.  My camera has an elevation and azimuth, measured from the front face vector of the character. So as the the player turns the camera turns with it.  So you can kind of imagine a stick from the character to the camera that keeps the camera's relative position to the character. Now, as the character turns and the camera collides with something you simply move the camera forwards along the stick until there is a clear line of sight to the character.  You can do this by checking for collisions in a line from the character back to the desired camera distance along the stick. Once the camera collision is clear (say the character moves again) the camera jumps back along the stick to it's desired distance. When the camera jumps back you can make a it a smooth transition if you don't want to jar you players perception.

Share this post


Link to post
Share on other sites

So basically instead of having the object's world coordinates be tide to the camera's world coordinates with a distance amount, I should have the camera be pulled by the object instead like a dog on a leash? Interesting idea.

I was also exploring other possibilities in my head such as using velocities. Once the object collides the velocities of both the object and camera can be tied together to move the same. Another thing I was thinking of using would be a large ellipsoid around the object and camera together with the object on one long end and the camera on the tail end, and check for collision on that but I don't think this would end up right. But it was a thought.  

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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!