Rotate actor clockwise / counter clockwise depending on the mouse position.

Hi,

The following image indicates what I am trying to achieve but I have some trouble understand what they mean with input required when I want to use the function IsMouseButtonDown. I will explain what I did so you’ll see my progress so far and understand where I am trying to go. All tips, tutorials, directions are welcome! :smiley:

First I have created a method to check if the user have clicked the actor or holds the button down and then continues to the next event. This works well. No issues here!

I am stuck at this part. So, once the ButtonIsBeenHold is triggered I want to check if the button is still down. When true I will rotate the actor to the position of the mouse and continue until the button is released. But before I can start I with this part. I’ am unable to understand the error I’m receiving. I need an Pointer Event for the function IsMouseButtonDown. Totally no idea what to do here.

Any idea how to solve this or other ideas/possibilities to achieve this method.

Kind Regards,

mouse X is one of the axis of the mouse (coordinate on screen etc)

have you tried this:
cee250c98224f319c024a8e40c0e4f1cf43b0fbe.jpeg

just right click n type right mouse button - comes with a free press n release output :wink:

Hi Ayretek,

Thnx for your response! :smiley: The right Mouse Button doesn’t work in my Actor blueprint. It does only work in my level blueprint.

Besides that I have to find another way because when you add a Boolean to the while loop. You’ll create an ifinite loop! :frowning:

Lets let the adventure continue! :smiley:

lol alright, adventure time

if you accessed the pressed & released, you shouldn’t need that while loop and personally unless it had a break condition I wouldn’t use it anyway. (there’s one with break btw) just execute or do what you want after button was pressed until it’s released. maybe :slight_smile:

don’t know what kind of actor you are using etc. for your BP but player BPs usually can use them as well as level, what you can do is branch a condition to the mouse button down variable node (in that pic) (just make it public then cast to and get or access it in that BP you are using)

The problem with the pressed and released method is that it only does the script once and that is not what I need. Let me rephrase what I’m trying to do here and explain how I think how I can achieve this.

The first picture shows that when I hold down the left mouse button over this specific actor, the actor rotates depending on the current mouse location. Think like it is an old volume button that you can turn to increase/decrease volume of your stereo.

So after verifying that the mouse button is hold down over this actor I have to check constantly if the mouse button is still down. This is needed to constantly update the location of the actor, when the mouse moves the actor moves too. I was thinking something like this: As long as the left mouse button is down is true (while-loop), i get the current mouse position and rotate the actor depending on the mouse position. If false, do nothing.

The problem I have now is to figure out the following error when using the function IsMouseButtonDown.

I think I have to add an array of all current player’s inputs that are active at this moment as reference to check if the left mouse Button is still down is in this list. But I haven’t figured out how to do this. I hope someone can help me out here.

k, everyone seems to like different methods, in the end we just want something to work and work the way we want, eh
(I don’t like using EventTick unless I just have to, so I usually try to use some sort of other event to drive program flow when possible)

have you tried just plugging in the GetPlayerController for the input yet?
(the player controller input in this case expects input as well I believe)

I did a search & came up with this post that covers a few scenarios that you might can use as well:
https://forums.unrealengine.com/showthread.php?476-Input-Held-Down

Tried the GetPlayerController aswell and that is not working either, the nodes are different. I’m going to try something with Get Input Key Time Down as used before. As long that it doesn’t return 0.0 it means the button is down.

Thanks for your help again Ayretek!

Much appreciated! It’s time for some more undiscoverd magic! :smiley:

hey np, I think it’s better to let people work their own problems out, and I learn a lot in the process.

had to check to see if what I mentioned at the start to make sure it would work, sort of a proof of concept:

4178e19f15e0b323f3bb9a121a1f6624aacfe9b5.jpeg

using the pic in the post up above to setup the RightMouseButtonDown bool variable then do what’s in pic above here in this post and see what happens.
humor me lol :slight_smile:

(the 2nd set to false in the original pulled from the release output probably isn’t even necessary in this case btw)

Yeeehaaa!!

I finally figured it out how to rotate clockwise / counterclockwise while following the mouse.
The following blueprints contains:

  • When you click once: The actor will rotate 45 degrees.
  • When you click double: The actor will return to the begin position.
  • When pressed down en move: The actor rotates while following the mouse and on release it will smoothly snap to the closed angle (0 - 45 - 90 - 135 - 180 - 225 - 270 - 315 - 360(0)).

Here are all the necessary Blueprints I have used to make this work. A tutorial will follow in the future. At this moment you have to help yourself with these pictures. I don’t know if this is the best method but it works.

ACTOR BLUEPRINT




ACTOR BLUEPRINT (MACRO)

FUNCTION LIBRARY BLUEPRINT



MACRO LIBRARY BLUEPRINT

I hope this wil help!