void Update() { playerBehaviour.Move(this.gameObject); if (Input.GetKeyDown(KeyCode.Space)) { if (playerBehaviour.GetType() == typeof(FPSBehaviour)) { Destroy(GetComponent("FPSBehaviour")); playerBehaviour = gameObject.AddComponent <EditModeBehaviour>() as EditModeBehaviour; } else if (playerBehaviour.GetType() == typeof(EditModeBehaviour)) { Destroy(GetComponent("EditModeBehaviour")); playerBehaviour = gameObject.AddComponent <FPSBehaviour>() as FPSBehaviour; } } }
void Start() { playerCamera = GetComponentInChildren <Camera>(); playerBehaviour = gameObject.AddComponent <FPSBehaviour>() as FPSBehaviour; //Setting the default behaviour as FPS mode. }