Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Joystick not capturing events(drag and click)

Discussion in 'UGUI & TextMesh Pro' started by Deep96, Feb 11, 2018.

  1. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9
    I want to convert the Unity's Survival Shooter game for mobile. I have added joystick using UI->Image and attached a Script to the Image. The class extends IDragHandler, IPointerUpHandler, IPointerDownHandler but none of the relevant functions respond except the Start() function

    I also tried taking input from Unity remote app but no luck.

    Unity's tutorial said to keep Canvas interactable to be unchecked. Now I have checked it for all of the elements. I have EventSystem in the Heirarchy.Also none of the UI elements are blocking the joystick. I tried sliding the Health Slider and it doesn't slide too.

    I can't figure out what is wrong with this game and stuck here for about a week. Does Raycast Target have anything to do with this? Currently its checked for all the elements.
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Is there a StandaloneInputModule component on the EventSystem, is it enabled, and are its inspector settings correct for the platform you're testing on?
     
  3. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9

    Currently the Build Platform is set to PC,MAC and Standalone. I did a lot of digging about the inspector settings and various attributes but feel that everything's correct. Will you please have a glance at the settings?

    EventSystem
    inspector_event_system.PNG


    Canvas
    inspector_canvas.PNG

    joystick
    joystick.PNG

    Outer Circle
    outer_circle.PNG

    Inner Circle
    inner_circle.PNG
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I don't see anything obviously wrong. Can you post the code to the Move Joystick? You can also test it in a new scene with just the joystick and EventSystem to rule out scene-based issues.
     
  5. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9
    As you said I tested by creating a new scene and it works. Do you have any idea why its not working in my Main scene?

    I moved MoveJoystickBackground to the last place in heirarchy and now the joystick works.
    But there another problem, ScreenFader which shows GameOverText appears below Joystick.
    I dont want joystick to be visible in ScreenFader.

    Heirarchy
    heirarchy.PNG

    ScreenFader
    screen_fader.PNG
     
    Last edited: Feb 13, 2018
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No, I don't. It's very common for people to have this problem when they have some invisible image or other component blocking the raycasts. You say none of the UI elements are blocking it. Could an invisible one be? Disable everything you can and see if it works.
     
  7. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9
    Yes, I realised that ScreenFader was blocking all the UI elements. But now theres another problem, I have updated my last reply. I appreciate if you please have a look at it?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I don't know how screen fader works, but why can't you just disable the screen fader game object until it is needed? Leave it below the joystick so it draws on top if you want the joystick to be hidden by it. Your only other option would be to disable the joystick game object if you want it to be invisible when screen fader is open, but that would not work as well visually because it would pop out. Enabling screen fader immediately before beginning the fade would have no visual artifacts and would work exactly as you want it to.
     
    Deep96 likes this.
  9. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9

    Thanks you so much @guavaman
     
  10. Deep96

    Deep96

    Joined:
    Jan 6, 2018
    Posts:
    9
    Thanks a lot! Its working as I wanted
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I'm glad it works.