Forum rules - please read before posting.

Click and Hold Mouse0 for ToggleCursor?

Has anybody had any luck setting up their mouse 0 input to control ToggleCursor on downclick and stop on upclick? I've tried both the old and new Unity Input Systems and haven't figured it out yet.

I'm trying to make single click escape room like WebGL game similar to this game built in unity: https://www.crazygames.com/game/laqueus-escape

Thanks!

Comments

  • Going by the WebGL game you linked to, I'm guessing this isn't so much about "ToggleCursor" exactly, as just being able to click-and-drag to rotate the camera?

    There's a couple of ways you could try this:

    1) Use First Person mode, then add a custom script to your scene or Player that toggles the cursor lock manually based on mouse input. For this, you'd need to remove "ToggleCursor" from your Input Manager, as this will override it:

    using UnityEngine;
    using AC;
    
    public class FreeAimWhenMouseHeld : MonoBehaviour
    {
    
        void Update ()
        {
            if (!KickStarter.stateHandler.IsInGameplay ())
            {
                KickStarter.playerInput.SetInGameCursorState (false);
                return;
            }
    
            if (Input.GetMouseButtonDown (0))
            {
                if (KickStarter.playerInteraction.GetActiveHotspot () == null)
                {
                    KickStarter.playerInput.SetInGameCursorState (true);
                    KickStarter.playerInput.ResetClick ();
                    KickStarter.playerInput.ResetMouseClick ();
                }
            }
    
            if (Input.GetMouseButtonUp (0))
            {
                KickStarter.playerInput.SetInGameCursorState (false);
                KickStarter.playerInput.ResetClick ();
                KickStarter.playerInput.ResetMouseClick ();
            }
        }
    }
    

    2) Instead of first person, set your Movement method to None, and rely on individual third-person cameras instead (listed as GameCamera ThirdPerson in the Scene Manager.

    This camera type supports drag-controlling, and if its Distance from target is small enough, it could be made to feel like a first-person camera. A similar trick was done for the "main view" camera in the Physics Demo.

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.