Disabling Player Control Using PlayableDirector Question

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;
            }
        }
    }
}

Hi DoctorFaux,
Apologies for the delay, I didn’t get the notification on this topic until this evening. I don’t have time to work up a fix script for your specific issue, but I will revist this topic tomorrow afternoon. I have a static solution that should actually work for any type of situation where you briefly need to steal control from the player or any other hcaracter.

1 Like

I’ve looked over this, and I think I need more information on how the IntroCineControlRemover was set up.

Each PlayableDirector should be in it’s own GameObject, with the respective ControlRemovers attached. It looks like your Intro is set to play on Awake… this means that the IntroCineControlRemover just needs to subscribe to it’s own PlayableDirector. The other control remover will subscribe to it’s PlayableDirector as normal.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms