I need to move/rotate an physics handle holding and object by pressing widget buttons.
Until now i can do this by holding down keyboard inputs.
I cannot achieve the same results by holding down widget buttons.
I though it would be something simple to do, but Im not finding a solution.
I need this to work because end-user will be interacting thru touch devices, no keyboards or other controller.
Keys will appear on screen/viewport
Thanks in advance
You need to better explain where you are stuck at. Is it a communication problem between the widget blueprint hosting the buttons and the blueprint of the physic handle?
The problem is that Widget Button do not behaves as keyboard button input.
I can control perfectly control the physics handle movement and rotation with keyboard. In this case with Y for up and U for down.
But i don´t know how use a widget button as keyboard input axis. If it´s possible.
Ok, so if I understand correctly, your system works with the InputAxis node because this node is called every frames. Now you want to do the same with two widget buttons : one that you hold to move the handle down and the other one that you hold to move the handle up. Is that correct?
A grown up approach here is to extend a button, wrap it in a widget and override its OnKeyDown.
A quick and dirty hackaround would look like this instead:
Pick your poison.
edit: And yet another alternative is to have a Player Controller input call a custom event inside the widget.
Could you explain a little bit the last alternative ?
You mean to communicate an input from Player Controller to a Widget BUTTON?..
Sure, providing you’ve extended the button - it then becomes a standalone widget anything can talk to. You can have a Custom Event feed data to an overriden onKeyDown or a Tick solution. It’s probably over the top, kind of depends on what you’re doing. For something simple go for the hackaround.
And yet another alternative is to use an Event Dispatcher from the widget to the Player Controller - this can be useful:
- you generally want as much functionality outside of the widgets as possible
- you may have stuff set up in the Player Controller already
- no need to create direct references and no expensive casting
- no more Accessed None errors if you lose your widget for any reason
edit: to clarify the Event Dispatcher thing:
In the widget:
in the Player Controller:
This allows you to hook up the buttons to the already existing setup you may have anywhere else. Also, becomes pretty much an indispensable way of sending a bunch of data once your interface becomes somewhat complicated.
Do tell if you get it to work the way you need!
Ok, yes. I need to keep all functionality inside my Player controller, so I go for your last alternative. Thanks you very much, man.
I promise I´ll come back to mark it as solved : )
Sir, you are a master.
I don´t understand the logic of EventDispatcher very well, i´m still learning but… is working!.
Thank you very much!!