Still Have Control

I’ve been pouring over this lesson and the last trying to figure out where I went wrong. When my PC crosses the trigger collider, my cinematic starts but I still have complete control, as do the enemies. I’m getting the correct print messages upon entering and exiting the cutscene, so I assume it’s something in the mover or fighter script not canceling property, but I’m not sure what I missed.

Also I get a null reference error upon entering/exiting the scene about the pb, though I thought we weren’t using that anyway.

If you’re still able to click and move, the issue is more likely the PlayerController itself…

Paste in your CinematicControlRemover for a start and we’ll take a look.

I TA 10 courses, so my brain is locking up about what the “pb” is… can you paste the actual null reference error (click on the error and paste in the stack trace at the bottom of the console).

I’ve attached a screenshot of my CinematicControl remover. I thought it was one of the components instead of the PlayerController because the enemies were also able to interact with the player during the cutscene.

I apologize about the pb variable. It was actually “pd”, the Playable Director, which you can see in the attached script. I appreciate the help.

For future code pastes, always paste the code itself rather than the screenshot. I can format the code after you paste it in, if needed (or you can select the text after you paste it in and press the </> button in the edit bar. It’ll be much easier to read for us old fogeys. It’s also easier for me to quote/cut and paste specific code to comment on or change, as you’ll see below.

That’s in the current design, actually, It’s best to put your cutscene triggers far away from enemies so that the enemies don’t murder your player while you’re watching the scene!

I suspect your issue is in Start…

GameObject player; //This is the reference value that will be referenced in Disable and EnableControl
private void Start()
{
    GetComponent<PlayableDirector>().played +=  DisableControl;
    GetComponent<PlayableDirector>().stopped += EnableControl;
    //Because the next line starts with the type declaration GameObject,
    //a new local reference value is created which masks the global reference value
    //meaning that the global player remains a null reference...
    GameObject player = GameObject.FindWithTag("Player"); 
}

remove the GameObject from the line GameObject player = GameObject.FindWithTag(“Player”); and you should be good to go.

player = GameObject.FindWithTag("Player");
1 Like

I can’t believe I watched this lesson and the previous one thrice each and missed that each and every time. Working as intended now, thank you very much Mr. Trotter. Apologies about the formatting, I’ll fix it for the next time! Thanks again!

1 Like

It’s actually a fairly common error. I’ve done it myself from time to time, though I seldom admit that in public, so this reply never happened.

2 Likes

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

Privacy & Terms