I know this is a easy answer and I am going to feel like a noob for asking it but I can’t find a answer anywhere.
How do I detach the mouse from the first person camera control. In other words I want the player to be able to interact with a gui without moving the camera all around in the background. Then when they hit quit on the gui it takes back control of the First person shooter control.
You’ll probably want whatever triggers your GUI to turn off the mouselook and character controller components on your player object.
function Start (){
playerPosition = GameObject.FindWithTag ("MainCamera");
playerParent = GameObject.FindWithTag ("Player");
}
function DoWhatever(){
playerParent.GetComponent(FPSWalker).enabled = false;
playerPosition.GetComponent(MouseLook).enabled = false;
playerParent.GetComponent(MouseLook).enabled = false;
}
This is a little snippet from how I managed this on my first real Unity project. When the script starts, it goes out and finds the GameObjects for the Camera and Player. Whenever DoWhatever gets called, it disables the FPSWalker, and both of the MouseLook scripts. Turning it on again is just setting those things back to true.
awesome thanks for the help
k it is close to working
here is what i have
var playerPosition = GameObject.FindWithTag ("MainCamera");
var playerParent = GameObject.FindWithTag ("Player");
playerParent.GetComponent("FPSWalker").enabled = false;
playerPosition.GetComponent("MouseLook").enabled = false;
playerParent.GetComponent("MouseLook").enabled = false;
the
playerPosition.GetComponent("MouseLook").enabled = false;
is giving a object reference is not set to an instance of a object.
At times it will not give that error and will work in the engine but not in the web player. I checked the class name and the tags and all are right,.
hmm since I can’t get an answer for the above, anyone else have an idea on how to get the mouse disabled when a gui pops up?
make sure you have the maincamera set to the main camera tag this may not be set by default. also i don’t know why this script calls for the main camera to be dissabled twice and this bit playerParent.GetComponent("MouseLook").enabled = false; seems to be looking for the Mouselook in the player object herevar playerParent = GameObject.FindWithTag ("Player");
as far as i know the mouslook goes onto the camera so i’d say check your tags and remove this line playerParent.GetComponent("MouseLook").enabled = false;
unless you have both mouse look scripts on the player and the camera.
I hope that works its been a while since i used the fps assets other than the walker script
thanks for reply
tags are set correct
it is giving me the
“object reference not set to an instance of an object”
from this line
playerPosition.GetComponent("MouseLook").enabled = false;
if I comment it out it stops the side to side look and the wasd movement but I can still look up and down.