Monday, December 16, 2013

Week 1 Day 1 - Camera Collision Detection

After getting some standard movement and camera controls set up, we started trying to handle camera collisions with objects.  Previously, and in the prototype, when the camera was moved into a solid object, it simply passed through, and we could see through the objects we were inside.

We tried a couple different solutions to this, including:

  • finding how far down the player had pulled the camera, after hitting an object.  Using that distance to find the position along the object
  • Simply pulling the camera closer, whenever we were hitting an object
When these methods proved to be unnecessarily complicated, we got the idea to use a raycast from the position the camera would be looking at, out to the desired camera position.  Using this cast, we can detect if we hit any objects in between the player and the camera, and set the camera at the position that we hit.  This way, the player's camera will never be obstructed by any objects.  This also eliminated us having to make a special case for when the camera's distance would place it on the opposite side of an object from the player (but not be hitting the object), this killing two birds with one stone.


Here's an image of the camera, as it intersects the platform below the player.  It is closer than the standard camera distance, and still clearly placed the player in an unobstructed view (as you can see from the white lines that show the camera's view).  This method is also REALLY smooth.  The previous methods were causing some large jittering as we moved the camera forward and back, trying to place it in just the right location for where we were hitting objects.  Doing the raycast gives us an exact point to place the camera (or a very close point, some optimizations will still need to be done to avoid clipping against the platform).

We have written up some goals for tomorrow:

  • Camera Polishing
    • Character Opacity - make the character become transparent as the camera get's close to it
    • Platform Clipping - place the camera slightly above the raycast hit position for collisions
  • Gravity
    • right now, it seems like the player falls too slow
    • also, listen to the John Mayer song while doing this
  • Ability Activation (basically placeholder right now)
  • Tighten character movement controls
  • Player Settings - store the data for this, don't actually make settings changeable yet

No comments:

Post a Comment