Hi ![]()
I’ve found a really awesome camera script that I’m now butchering, and I’m just wondering if i can make the camera fixed while it follows targets (The camera was originally for a SSB camera - zoom in on close together targets, and out when further apart) (Which works well in 2d, but i’d like to put it in 3d, think - http://www.youtube.com/watch?v=Y83pOQO4tbk&feature=related. Currently the camera rotates around the object, in a circle, is there anyways I can lock it, or limit its movement?
Thanks
var target : Transform; var target2 : Transform; function LateUpdate () { var targetsHeading: Vector3 = target2.position - target.position; var perp: Vector3 = Vector3.Cross(targetsHeading,Vector3.up);
//point looked at between
var halfway: Vector3 = (target.position + target2.position) *
0.5;var dist: float = Vector3.Distance(target.position,target2.position);
var distScale: float = -2.3; var camHeight: float = 4.5; var minDistance: float = 0.1; // Or whatever... camera.transform.position = halfway + perp.normalized * (dist *distScale + minDistance) + Vector3.up
camHeight;
transform.LookAt(halfway);
}
Original thread here - http://forum.unity3d.com/threads/41311-Camera-Help
http://forum.unity3d.com/threads/41076-Solved-Camera-To-follow-and-rotate-around-2-objects