Changing ZOrder of virtual joysticks.

How can I change the ZOrder of the default virtual joysticks? I have a UMG Image that is full screen and it’s ZOrder is 1 but I have to put the ZOrder to -12 to have control over the virtual joysticks. So I just want to move the virtual joysticks above 10.

I think you would have to change the source.

I poked around in the source and found the spot where the viewport widget is added.

Assuming you are on the 4.11.1-release tag, in the file Engine/Source/Runtime/Engine/Private/PlayerController.cpp on change line 1078 from:

			LocalPlayer->ViewportClient->AddViewportWidgetContent(VirtualJoystick.ToSharedRef());

to

		LocalPlayer->ViewportClient->AddViewportWidgetContent(VirtualJoystick.ToSharedRef(), 11);

(11 is the arbitrary number above 10 that I chose)

Thanks! Going to try this now.

Question, do I have to built UE4 from source for this to work?

I did what you said but the ZOrder didn’t change. I install you UE by the launcher if that means anything.

Yes, you would need to actually compile the engine from the source you modified for this to be able to have any effect.

Darn. Ok. Thanks for your help. Wish I didn’t have to compile.

Just hint: you don’t need change engine cpp if you just override virtual void CreateTouchInterface() in your own PlayerController class

I found another solution. When you add HUD, just make their ZOrder -1. That way, our joystick is always on top. You don’t need to change source code.

1 Like