Forum rules - please read before posting.

How to center cursor?

Heyo, my game uses direct control for the most part but sometimes I switch to mouse cursor control. When I do, it would be nice if the cursor was centered so it's not missed by the player. Is there an easy way to do this?

I'd also like to treat the cursor like any object with an animator so I can send triggers to it and thus switch animations and states on it that way. Is this doable?

Thanks!

t

Comments

  • Unity cannot force-set the position of the mouse (i.e. system) cursor. However, if you rely on AC's simulated cursor, you can set the position through script using:

    AC.KickStarter.playerInput.SetSimulatedCursorPosition (newPosition);
    

    To use the simulated cursor, set your game's Input method to Keyboard Or Controller. To move it with the mouse, map inputs named CursorHorizontal and CursorVertical in Unity's Input Manager to the mouse X and Y axes. These inputs can be duplicates of the default "Mouse X" and "Mouse Y" inputs that come included in a fresh Unity project.

    To be able to add animation effects etc to your cursor, you'll have to make use of Unity UI, and have a RawImage component take the cursor's position, which can have an Animator attached. A script for this can be found on the AC wiki here.

  • Thanks, Chris! :smile:

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.