I have an idea for a camera tracking behavior that I am looking for hints on implementing:
I'd like to apply a force to the camera as a linear function (with a defined maximum force) dependent on the camera's current position to this point:
This point would move to be a specified distance from its target in whatever direction it needs to do so. Additionally, it would use something similar to the "Place Object On Surface" menu item to furthur position the point. Then it would offset the point by a defined "elevation" variable.
The effect should be a smooth chase camera that follows terrain and never goes through objects.
After writing this now, I see it would be a problem for any tall objects on the terrain, like trees.
Can anyone offer some hints at what sections of the Script Reference would be good to look at for this? Or a better approach is most certainily welcome.
I guess what I'm looking for is "lazy" object parenting with collisions, so you never go under the terrain in an ugly way.
* Don't use rigid bodies to create a follow camera
* Take a look at the ray cast functions in dynamics. Cast a ray downwards, to find the intersection with the terrain. Using Debug.DrawLine can save you a lot of time when debugging.
* Quaternion.Slerp, Quaternion.FromToRotation, Quaternion.AxisAngle, Quaternion.LookRotation are your friends.
* That said, I am going to add a sample script for follow camera to one of the next beta releases.
Making a good follow camera that works in all cases is a hard problem. I'll try to make the follow camera as good as possible.