Question by
Cee-Ach · Mar 15, 2017 at 06:56 PM ·
scripting problem
Disable character controller when second camera is on.
everything worked, from disabling fps camera to enabling the other camera when stepping on the cube. The only problem is I want to disable the script for fps controller so I can stop the movement of the character.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityStandardAssets.Characters.FirstPerson;
public class Move : MonoBehaviour {
public Camera firstPersonCamera;
public Camera MainCamera;
public int x = 0;
public void ShowOverheadView()
{
firstPersonCamera.enabled = false;
MainCamera.enabled = true;
}
public void ShowFirstPersonView()
{
firstPersonCamera.enabled = true;
MainCamera.enabled = false;
}
void OnTriggerEnter(Collider other)
{
ShowOverheadView();
x += 1;
}
void update()
{
if (x == 1)
{
GameObject.Find("Player").GetComponent<FirstPersonController>().enabled = false;
}
else
{
GameObject.Find("Player").GetComponent<FirstPersonController>().enabled = true;
}
}
}
Thank you!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612113241im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Script wont execute unless selected in editor - Unity 2018.3.6 1 Answer
New problem. 1 Answer
Why does my GameObject destroy itself? 0 Answers
Movement Flipped in Game View? 0 Answers