Move the camera

I’m working on a code, if playercontroller = false…then you can move the camera.

but the camera won’t work =/

here’s the code:

using UnityEngine;
using System.Collections;

public class Cammouse : MonoBehaviour {

public float Cameraspeed;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
	
	if(Player.Playercontroller == false)
	{
		
		float camMoveH = Input.GetAxis("Horizontal") * Cameraspeed * Time.deltaTime;
		transform.Translate(Vector3.right * camMoveH);
		
		float camMoveV = Input.GetAxis("Vertical") * Cameraspeed * Time.deltaTime;
		transform.Translate(Vector3.down * camMoveV);
		
	}
	
	//transform.position = new Vector3(Input.mousePosition.x,Input.mousePosition.z);

}

}

and this is the Player code were I made the bool for Playercontroller:

using UnityEngine; using System.Collections;

public class Player : MonoBehaviour {

private float TimeDifference;

public static int Health = 100;

public float Playerspeed;

public static bool Playercontroller = false;


public static Player Instance;
// Use this for initialization
void Awake () 
{
    Instance=this;
}

// Update is called once per frame
void Update () {



    if (Playercontroller == true)
    {
    float amtToMoveH = Input.GetAxis("Horizontal") * Playerspeed * Time.deltaTime;
    transform.Translate(Vector3.right * amtToMoveH);
    float amtToMoveV = Input.GetAxis("Vertical") * Playerspeed * Time.deltaTime;
    transform.Translate(Vector3.forward * amtToMoveV);

    }

The problem is that you are accessing the Player as a static class! it would be simpler and generally easier to debug if you just put a reference to the player in your camera script:

public Player player;

if you put this at the top, you can assign the Player in the unity editor, and then it will work for you. Just use the non-capitalised player instance reference instead of the capitalised Player class reference!

you are missing a part of your script, namely the one where “Player” and “Playercontroller” is defined. I guess though, that Player.Playercontroller is an instance of something, so you need to check against null and not false:

if(Player.Playercontroller == null)
{
    // ...
}