Welcome back,
Today we are going to finish up the basic camera controls. The next two things we need to add is the zoom in and the camera colliding with objects.
Adding in the Zoom:
Spin around and zoom in and out |
When studying the Wind Waker camera we noticed it isn't just a linear zoom in and out. We need to make a bezier curve for the camera to follow. We also notice the camera is always looking at a point in link's head when zooming in and out.
This is the results:
But when testing the camera something else came up. Thee speed at which you can rotate the camera around link changed based on how zoom in you were.
Its a small change but it is there. It goes from about 1.3s to make a complete turn when zoomed out to about 1.7s when zoomed in. I added in a a little adjuster to the sensitivity when zoomed in and when fully zoomed out.
Camera Collider:
Next we need to implement the camera collider.
As we can see from these examples the camera wont collider with small objects like tree trucks, mail boxes and bushes, but it will collide with walls, cliffs and small rocks. I need to set up a little scene with a little more detail to test out the camera collider. I also need to add in some layers so the camera knows what it can collide with and what it can not.
I set up some obstacles: a house, a rock, a mailbox and a couple of trees. The trees and mailbox are on a "Decor" layer meaning the camera's collider will ignore collision with them and the ground, walls, house and rock are on a "Environment" layer in which the camera will collide with. All these parts have box colliders on them (for simplicity) which allows physics for our player and camera.
The camera got removed from being parented to the player so that I can make a prediction of where I want it to go and allow testing before snapping the camera to that location. (May be useful once we start with Z-Targeting). It also helps with SOLID principles with having each script/game object be in charge of one thing.
Thanks SphereCast :D |
Wind Waker camera also put some care into keeping sure the camera clipping plane never goes through the walls. Which I easily implemented with RayCasting a sphere the size of the clipping plane.
That's it for today. Next time we will start getting into some more camera features that will lead into the combat system.
Commit: 1225f31
Comments
Post a Comment