Question by
iTz-_-Suddo · Sep 19, 2015 at 06:10 AM ·
cameramovementmouseeditor-scriptingbuild-error
Why is my MouseLook script not letting me look up?
//MouseLook
using UnityEngine;
using System.Collections;
[AddComponentMenu("Camera-Control/Mouse Look")]
public class MouseLook : MonoBehaviour {
public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityX = 15f;
public float sensitivityY = 15f;
public float minimumX = -360f;
public float maximumX = 360f;
public float minimumY = 0f;
public float maximumY = 0f;
float rotationY = 0f;
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityX;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y,0);
}
}
void Start()
{
if (GetComponent<Rigidbody>())
GetComponent<Rigidbody>().freezeRotation = true;
}
}
//NetworkManager
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public GameObject standbyCamera;
SpawnSpot[] spawnSpots;
void Start () {
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
Connect();
}
void Connect()
{
PhotonNetwork.ConnectUsingSettings("MultiFPS v001");
}
void OnGUI()
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby()
{
Debug.Log("OnJoinedLobby");
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed()
{
Debug.Log("OnPhotonRandomJoinFailed");
PhotonNetwork.CreateRoom( null );
}
void OnJoinedRoom()
{
Debug.Log("OnJoinedRoom");
SpawnMyPlayer();
}
void SpawnMyPlayer()
{
if(spawnSpots == null)
{
Debug.LogError("WTF!?!?!");
return;
}
SpawnSpot mySpawnSpot = spawnSpots[ Random.Range ( 0, spawnSpots.Length) ];
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standbyCamera.SetActive(false);
//((MonoBehaviour)myPlayerGO.GetComponent("FirstPersonController")).enabled = true;
//((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true;
myPlayerGO.transform.FindChild("FirstPersonCharacter").gameObject.SetActive(true);
((MonoBehaviour)myPlayerGO.GetComponent<MouseLook>()).enabled = true;
}
}
Comment
how about cropping to the relevant parts, that's a lot of code?
Yea mouselook script and the bottom last line of code is the only thing you should look at.