Unity3d. I am trying to move an object with Camera around a fixed terrain (Mountain), while staying an set distance from its edge. I have the camera set to lookAt the mountain, and I want to circle the mountain. I was thinking about sine wave for circular motion but its not an exact circle as I need to move in or out to maintain the fixed distance from the mountains edges.
It looks like I might need transform.RotateAround(..), but what about the adjusting to maintain a fixed distance from the edge of the uneven surface while maintaining the circular motion.
transform.RotateAround (Vector3.zero, Vector3.up, 20 * Time.deltaTime);
Update: Here is my current script for circling around mountain as first person object:
function Update () { var mountain : GameObject; mountain = GameObject.Find("QuantumCold_B"); transform.RotateAround(mountain.transform.position, Vector3.up,20 * Time.deltaTime);
}
Unfortunately there are two problems:
1) The first person object appears to be falling or maybe its the main camera, but in any even there is a game screen looks like its falling below the mountain. 2) it is the mountain that seems to be rotating. Do I need to switch the main camera to be the first person camera. Why does the mountain appear to be rotating?
Quaternion rotation = Quaternion.Euler(0, _rotY, 0); transform.position = target.position - (rotation * _offset); transform.LookAt(target);
\$\endgroup\$