Adjusting Virtual Joystick Opacity from C++

Is there any way to set the opacity of the virtual joystick from C++? What I’ve done is created a player controller class and added a getter for the virtual joystick, but I can’t seem to find any methods for setting its opacity. I tried using ‘SetRenderOpacity’, but it didn’t seem to work. Let me know if any of you have a solution for it. :slightly_smiling_face:

The actual thing i m trying to do is , make it fade when the joystick is not active, and yes i know it has a built in thing to do it from the Touch Interface but wont work if “PreventRecenter” is ticked, i want that to enabled as well as have it fade and be not visible when not active/when player touch it! I want the joystick to me fixed on a position.

Also tried using the SetJoystickVisibility Method

TSharedPtr VirtualJoystick = PlayerController->GetVirtualJoystic();
if (VirtualJoystick)
{
VirtualJoystick->SetJoystickVisibility(false,true);
}

this also didnt seemed working

Hi, I’m not sure if you can change it directly in default virtual joystick - try changing ActiveOpacity and InactiveOpacity variables.
But if this doesn’t work, just copy DefaultVirtualJoysticks class from the Engine Content, adjust opacity to your needs and change it to use your new VirtualJoystick.

Hey ActiveOpacity and the other one are protected so cant access it!

Another thought is to create a new class inherited from SVirtualJoystick

But i think i cannot find the cass when trying to create from the engine

Ah right, sorry.
But default engine virtual joystick inherits from UTouchInterface. It definitely works to create your own, as I’ve done this for my game. You can even change touch interfaces in runtime.

So i could just create a TouchInterface class and access from it or smth?

Find this class in the Engine content:


Duplicate it and move to your own project content - adjust all needed variables.

Change in project settings to use your new touch interface:

I have done that already, the problem is i want the joystick to be fixed in a pos by enabling Prevent Recenter but if you do so, the joystick will stay active and wont disable when not in use

I think the only way now is to edit the source file and build

I see sorry, it indeed doesn’t change opacity when you set PreventRecenter to true.
You can access touch interface from PlayerController, CurrentTouchInterface protected variable.

It works very weird but maybe you can work something out from this.

void AVIPlayerController::ChangeTouchInterfaceOpacity(float Opacity)
{
	CurrentTouchInterface->ActiveOpacity = Opacity;
}

This didn’t work out of the box, but sometimes worked in configuration with reactivating the touch interface like this:

But as I said it’s pretty weird, once it works, then it doesn’t… Good luck with finding the solution!

Yep, i tried that and it works sometimes and sometimes not! Tried finding some other way but seems not possible unless i change the source file some what to my needs!

Been trying to find some way but not able to…