Forum rules - please read before posting.

How to enable and disable AC's cursor interaction(So clicking doesn't do anything)

So I'm having this tiny bit of an issue where I get a null reference error for the PlayerInput.cs class. I'm pretty sure its because I have two different canvas and cameras, 1 Is main camera and canvas, and the other one is for Turn based combat BattleCamera and canvas for the Battle HUD etc.

Basically when I enter combat, it changes to my battle canvas and camera so clicking anywhere will result in null reference error. It doesn't actually crash the game or stop anything from working but it just pops up repeatedly on console every time I click when I'm in battle.

What I want to do is Disable the AC mouse interaction when I enter the battle and then enable it when the battle is over. What line of code will I need to do this?

Check the link to see the error: https://imgur.com/a/0DZRWqr

Thanks

Comments

  • You can disable AC's Input system with the SetInputSystem function.

    AC.KickStarter.stateHandler.SetInputSystem (false);
    
  • Awesome thank you

  • edited June 2021

    @ChrisIceBox Sorry Chris, just wanted to add another issue here since it relates to my previous question.

    Now after building the game and running it using the .exe, I noticed that the line of code you suggested disables the interaction but the mouse icon is still frozen in place in my Battle scene.

    In addition to that, my cursor(I'm guessing unity's default Cursor) in battle becomes invisible but still active. So I was wondering what you can suggest to me.

    I need to switch between AC's cursor and Unity's default cursor. So Default cursor for Battles and when not in battle, it will use AC's mouse cursor and interaction.

    I'm currently using this style and it works but not sure if its the right way or it will break something?

                //Switching back to AC's Mouse cursor and interaction when battle is over
                AC.KickStarter.stateHandler.SetInputSystem(true);
                AC.KickStarter.stateHandler.SetCursorSystem(true);
                Cursor.visible = false;
    
                //Switching to Default Cursor and disabling AC's Mouse cursor and interaction When in Battle
                AC.KickStarter.stateHandler.SetInputSystem(false);
                AC.KickStarter.stateHandler.SetCursorSystem(false);
                Cursor.visible = true;
    
  • Disabling the input alone will not disable AC's cursor - you will need to disable the cursor system separately as you're doing if you want to hide it.

    The code looks OK - so long as you call it at the right times, it should be fine.

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.