So I have an intro sequence because I made my skybox rotate and wanted to showcase that in the beginning. (Second bit of code) (First bit is the one we did together) Anyways intro control remover is working great (I can just adjust the float for the length of the intro video) but… now I still have control during my second cinematic (first bit of code).
I disabled my intro sequence and the second cinematic works fine. So I believe this means that the CinematicControlRemover enables and disables are getting called on the intro and not a second time for some reason.
Is there a reset mechanism I can use for the Playable Director or a way to say to do this for multiple cinematics? Right now I’m thinking about just serializing another field and going with an adjustable timer.
currently searching docs
using UnityEngine;
using UnityEngine.Playables;
using RPG.Core;
using RPG.Control;
namespace RPG.Cinematics
{
public class CinematicControlRemover : MonoBehaviour
{
GameObject player;
private void Start()
{
GetComponent<PlayableDirector>().played += DisableControl;
GetComponent<PlayableDirector>().stopped += EnableControl;
player = GameObject.FindWithTag("Player");
}
void DisableControl(PlayableDirector pd)
{
player.GetComponent<ActionScheduler>().CancelCurrentAction();
player.GetComponent<PlayerController>().enabled = false;
}
void EnableControl(PlayableDirector pd)
{
GameObject.FindWithTag("Player");
player.GetComponent<PlayerController>().enabled = true;
}
}
}
using RPG.Control;
using UnityEngine;
namespace RPG.Cinematics
{
public class IntroCineControlRemover : MonoBehaviour
{
GameObject player;
[SerializeField] float introLength = 5f;
float timer = 0f;
private void Start()
{
player = GameObject.FindWithTag("Player");
player.GetComponent<PlayerController>().enabled = false;
}
private void Update()
{
timer += Time.deltaTime;
if (timer >= introLength)
{
player.GetComponent<PlayerController>().enabled = true;
}
}
}
}