- Home /
How to disable the mouse look on a Top down second camera
I have added a second camera to show a top down map. I parented it to the main camera so it inherits the players movements. I have altered the depth and size of the second camera to show its view in the lower left. How do I disable the mouse look control on the second camera so it remains fixed-looking straight down?
You could have it track the first camera position rather than move via parenting. This way it will stay just how you want without any rotation, you can either keep in at the main camera height or add a height offset to the main camera y position when moving it.
Answer by MrSoad · Nov 12, 2014 at 11:33 PM
If your "Main Camera" is still called this, then this script should do what you want (it's in js) :
#pragma strict
//Object/Script access vars.
private var oMainCamera : GameObject;
//Transform vars.
private var tMy_Transform : Transform;
private var tMain_Cam_Transform : Transform;
//Height Adjustment var.
private var fMap_Cam_Height_Adjustment : float;
function Awake () {
//Connect to Objects and Scripts.
oMainCamera = GameObject.Find("Main Camera");
}
function Start() {
//Initialise vars.
tMy_Transform = transform;
tMain_Cam_Transform = oMainCamera.transform;
fMap_Cam_Height_Adjustment = 20f;
}
function LateUpdate() {
if (oMainCamera != null) {
tMy_Transform.position = Vector3(tMain_Cam_Transform.position.x, (tMain_Cam_Transform.position.y + fMap_Cam_Height_Adjustment), tMain_Cam_Transform.position.z);
}
}
Remember to un-parent you map cam from your main cam for this to work, adjust the height offset to whatever you desire.
Thanks so much. Pardon my ignorance but where exactly does this script go? Do I add it as a component to the main camera?
No you place it on your map camera, it will then work out it's own position by reading the $$anonymous$$ain Camera position.
Yep, sorry it was well past midnight when I wrote this(vote up for you :D ), I will change it in the code above for completeness. Feel free to close this question by accepting my answer :)