So I have a scene that starts out with a camera panning across the map. I have it set so when the user presses x, the gameobject that has the panning camera (the gameobject is named cinacam), will be disabled. How can I code my script to also activate first person controller as soon as the panning camera is disabled?
Since you didn’t specify a language, I chose C# for you. You want to do something like this, although this is quite simple, it may be sufficient for your needs.
All you’d need to do is drag in your Player and Camera GameObjects into the fields in the inspector and hit play, then x to activate it. It will destroy itself or work repeatedly depending on how you set the destroyWhenDone flag.
using UnityEngine;
using System.Collections;
public class CameraSwitcher : MonoBehaviour
{
public GameObject cinaCam;
public GameObject player;
public bool destroyWhenDone = true;
void Update()
{
if (Input.GetKeyDown(KeyCode.X))
SwitchCameras();
}
void SwitchCameras()
{
cinaCam.SetActive(!cinaCam.activeSelf);
player.SetActive(!player.activeSelf);
if (destroyWhenDone)
Destroy(this);
}
}