Forum rules - please read before posting.

Simple Cam + Constrained Script - moves about when in options menu

edited October 2021 in Technical Q&A

Hello,

This is a fun one.

I've got a simple / basic camera setup with the constrained first person script:

If this camera is active when the pause menu appears everything correctly pauses, but, if the player then selects a sub-menu like options the camera starts to move with the cursor. Like so:

Both the pause menu, and option menu, have pause game when enabled set to true:

I want to prevent camera movement entirely when in these menus.

I'd love to know why the camera movement would be disabled in the pause menu and not in the options menu? How does the pause menu block the movement?

Comments

  • edited October 2021

    Sorry, I'm an idiot. The answer is right there in the constrained script:

     private void Start()
            {
                pauseMenu = PlayerMenus.GetMenuWithName("Pause");
            }
    
            private void Update()
            {
                if (pauseMenu.IsOff())
                {
                    if (lookAtTransform != null)
                    {
                        UpdateLookAt();
                    }
                    else
                    {
                        Vector2 inputVector = new Vector2(player.GetAxis(xAxisName), player.GetAxis(yAxisName));
                        AddInput(inputVector * inputSensitivity);
                        UpdateLerpForward();
                    }
                }
            }
    

    I can just modify this to also ref the options menu and that should solve it.

    Question though: is there a way in AC of having the pause menu still register as active when in sub-menus like options? Sort of like it being a parent that is always true when in sub-menus. Or is the best practice to treat menus seperately and add them all individually into any checks?

  • You can check StateHandler's IsPaused() function to determine if the game is currently paused - regardless of which menu is causing it to be so.

    I've updated the wiki with this check.

  • Ah yes, that would be a good catch-all.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.