- Home /
How can i make both two cameras to follow the player but only one with control on player ?
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:
When the game view is from the Main Camera don't control the player at all.
When clicking escape and switching to the Camera view now to have full control on the player.
When clicking again the escape key Main Camera view no controll at all.
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.
Your answer
Follow this Question
Related Questions
How can I instantiate a prefab/s in all loaded scenes or in selected scenes from list ? 1 Answer
How can I add a speed factor to the script ? 0 Answers
Unity 5 C#, having a script show up in a path in the Editor 1 Answer
How can i make the circle to be drawn not from the top but from the camera view top ? 1 Answer