have two cameras. One is the Main Camera and the second is Camera is added. I put both cameras under as child the ThirdPersonController.
The problem now is i can't move the player, when i use the WSAD keys it's rotating the player but not moving it anywhere.
The script is attached to a empty gameobject and the escape key click switch is working. But when it's on the Camera view i can't move the player. When it's in the Main Camera i want that i won't be able even to rotate the player.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainMenu : MonoBehaviour
{
int count = 0;
public Camera _mainCamera;
public Camera _camera;
// Use this for initialization
void Start()
{
_mainCamera.enabled = true;
_camera.enabled = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
_mainCamera.enabled = !_mainCamera.enabled;
_camera.enabled = !_camera.enabled;
if (count == 0)
{
count = 1;
}
else
{
count = 0;
}
}
}
}
So this is the logic as i see it:
1. When the game view is from the Main Camera don't control the player at all.
2. When clicking escape and switching to the Camera view now to have full control on the player.
3. When clicking again the escape key Main Camera view no controll at all.
4. Both cameras should follow the player and the cameras should keep the original positions all the time so when ever i click escape in the game it will switch between the two view. So i need somehow also to keep the prepective of the views.
![Main camera view][1]
![Camera view][2]
[1]: /storage/temp/88883-ss66.jpg
[2]: /storage/temp/88885-ss67.jpg
↧