Announcement

Collapse
No announcement yet.

How do I centre a single virtual joystick for all devices?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I centre a single virtual joystick for all devices?

    Hi,

    I'm having a little issue trying to centre the 'LeftVirtualJoystickOnly', let me elaborate

    I know I can go into the settings and manually type in X=312 to centre the joystick in portrait mode for the Galaxy S9 for example. But as soon as I change device to landscape mode the 'Centre' position changes, as the screens width changes from Portrait X=624 to Landscape X=1480. Therefore the centre position is no longer at X=312. And as such I would assume this to also be the case when publishing to other devices, as we all know mobile screens vary greatly, so even if I limited the game to portrait only, I assume I would still have this issue on other mobile devices?

    Is there a way to auto detect the centre of current device screen and position the virtual joystick at that location???

    GetScreenWidth/2 ???

    Thanks for taking the time to look

    #2
    https://docs.unrealengine.com/en-US/...ors/index.html

    Comment


      #3
      Hi IslandPlaya,

      Thanks for the reply but I have no idea where the widget for the built in 'LeftVirtualJoystickOnly' is, I have had a look through the engine content, but I cannot find it. I have always just added these in by going through the Edit>Project Settings> Input> Mobile >Default Touch Interface.

      Is there a way to do this without me building a new one from scratch through a widget.

      Comment


        #4
        I see what you mean. You could have an invisible widget centred on the screen using anchors, read the xy value of that and set the position of your joystick to match. I don't do mobile dev anymore so perhaps someone else can offer a better solution. Good luck!

        Comment

        Working...
        X