Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question UI Joysticks competing with mouse/swipe input

Discussion in 'Accessibility' started by jamjam1000, Oct 23, 2023.

  1. jamjam1000

    jamjam1000

    Joined:
    Sep 22, 2023
    Posts:
    3
    Hi,

    I am using the Unity Third Person Starter Asset out the box, I have slight adjusted the projection and angle of the camera/cinemachine so that it now looks like an isometric game, the player movement works perfect.

    All I require now is that camera orbits the player and snaps at 45 degree increments (this is import to the purpose of the game). I have a empty game object called CameraPivot which is now the parent of the main camera. CameraPivot has a script attached to it that allows you to orbit the empty game object by dragging the screen with a mouse and it will snap to the nearest 45 degree.

    Everything works perfect on PC, but, this needs to be built on WebGL so that it can be accessed on the fly for PC and Mobile browsers. So the problem is, when on mobile, controlling the player using the UI joystick also picks it up as a mouse input. As a result, when the player is moving, the camera is also trying to orbit, so they are both are constantly competing with one other. How would I go about fixing this?

    I've spent countless hours researching for a concise fix and I'm also a Uni student and I think my priorities have been terrible the past couple weeks, I just cant wrap my head around this, and wish there was a clear solution to this as I can see this easily being a common problem. Due to also being noob in my game development journey I have poor scripting skills but I'm learning a lot, I hope this has a simple solution.

    I'm assuming this is an issue to do with the mouse input and not an actual UI swipe input? Could I simply disable the script on initial touch when selecting a UI element, or could I translate the script for it to work with the input system somehow? If I could, how would that look in a script? thank you to those who read through my concerns for what has left me slightly traumatized, thank you.