I’ve been trying to make a widget, in this case player controls graphics to appear when the character stops moving and disappears when the player starts moving for a FPS style application but have no luck so far. Can anyone point me in the right direction? Thanks.
You can *Get *current axis mapping values on *Tick *and check whether at least one of them is greater than zero.
You can use axis mapping execution, *Compare Float *and run it through a Gate / fire a macro that shows / hides the widget.
You can the length of Get Last Update Velocity vector and check if it’s greater than 0. This will work even when the player is moving but no keys are being pressed, as in falling, sliding, being pushed - not sure if desired.
The most basic setup:
That´s exactly the way to go, if you add a print string node and attach the value to it you Will see that when you move it becomes 1, and when you dont it becomes cero… the real problem its actually that you canot see this effect at the BP because you always see the orange thing working, moving or not, but if you add a print string you Will notice this more clearly, now you only need a Branch and set it to true and create the widget if this value is = > to 1 or false if this value is <= to 0, by doing this you Will be able to flip the widget to on and off.
But i´m not sure if i´ll do this by following the BP image shared before, since it will require a Tick check…. and you know constant ticks can be tricky and affect fps if there is too many, i would use a easier approach and use a Branch after the movement node and as condition of this Branch and instead of using the true false idea, you can just use an “==” node, connet the first Green pin to axis value and in the second pin, leave it to a custom number: 1, if its true (= to 1), create the widget, if its false, destroy this widget, remember to be specific to wich widget to destroy everytime by using “Get all widgets of class” and select the specific widget if not it will remove all widgets in the game.
This is actually a pretty bad advice for a lot reasons:
- first of all, axis mapping fires every frame, just like Tick - you can put a Compare Float node there but this is completely irrelevant from performance perspective anyway
- creating and destroying widgets for this is really bad, it’s expensive, memory hungry and needs to be garbage collected every time the player moves… Hiding / Showing or Adding / Removing from the viewport is virtually *free *in comparison
- if you’re using Get all for something like this, just don’t [HR][/HR]
If you truly wish to improve what I posted, put a couple of Do Once nodes prior to checking whether the widget is in the desired visibility state.
Thanks for all the help, I’ve managed to get it to work by placing the following setup in the character blueprint.
Hope this will be a good reference for anyone doing something similar in the future.
It’s not, you’re removing all widgets from the game every frame…
you just did what i told you not to do…
you Will destroy every widget in the game every time your character stops walking. I dont think discarding the widget every time you stop moving is as performance consuming as having a tick every second either you move or you don´t, but… if you want to follow “Everynone” advice wich is also valid, since making invisible those widgets its also an ok option, you can create all the widgets you want at event begin play, and then make them invisible, after moving node you can flip visibility with a Branch, but really… adding a == after the moving node is not as consuming as an extra tick, considering you already have the axis ticking every time wich now makes 2 ticks, but adding a == that Will only trigger if you move, is a great idea, and you won´t need 10 nodes to do something that perfectly can be done with 2 or 3, but either “everynone” idea or mine, both will work Ok, but take in consideration that if you have tons of AI enemies… adding 1 extra tick constantly checking if your characters is moving is a worst idea than using the axis tick wich already is mandatory to move, an extra tick is certainly going to affect your performance.