Sunday, April 9, 2017

unreal 4 - How to make my character walk by clicking and holding the mouse button?


I created an Action Mapping using the right mouse button as a reference.


The Action Map is called "Andar" (walk in english).


In the character code, I call this Action Mapping and in it I make the character walk by clicking the right mouse button (on Floor):


enter image description here


But I would like the character to continue walking if the player clicked the right mouse button and held.



Like Set Destination (action mapping from Unreal).


Other places I searched:


https://www.youtube.com/watch?v=AIPPXGFkjF0


https://answers.unrealengine.com/questions/134746/hold-button-for-few-sec-and-play-event.html


It's a simple problem, but I can't find anything about. Not exactly. The problems I found in my search are not the same as my problem. Even changing the words and terms I was not successful.



Answer



With the help of the answer to this question:


https://answers.unrealengine.com/questions/438398/a-simple-question-about-click-press-hold.html


I discovered to solve my problem.





  • Add a boolean variable




  • Set it to true every time the mouse button is pressed




  • Set it to false every time the mouse button is released





  • Insert a While Loop that only ends when the boolean variable is false.




Code:


enter image description here


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...