One click to rule them all

Hello good people, could someone please help me and provide a solution on how to use mouse click to do several things? If you click once, the player will move there, if you hold the click the camera can be rotated, and when I double click on an interactive object it will interact. I was able to set up that single click moves, I can rotate the camera and the double click is recognized, but when I double click it also implements single click movement and sometimes while I rotate the camera it implements also single click. I am not gonna post the spaghetti of blueprint but I’m sure that someone smarter can provide a much simpler solution.

1 Like

Hi there,

You can make a very very simple moderator if you like. When player click LeftMouseButton, you can have a very brief delay to decide what the click actually meant.

1st Click (ButtonDown)-> SetTimer (PendingClick)
1st Click (ButtonUp) → bool b1stButtonUp
2nd Click (ButtonDown) ->CancelTimer(PendingClick) → DoDoubleClickAction(Interact)

Timer(PendingClick) → if (b1stButtonUp) → DoSingleClickAction(Move)
→ else → DoCameraMove

Happy developing.

PS : I don’t generally utter here but.

Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk, agh burzum-ishi krimpatul :eye:

2 Likes

@RedGrimnir Wow, thank you for such a fast reply. I just got home from work, and I will try your suggestion. I am relatively new to UE so I am having hard time visualizing from your description the nodes that are need and what is connected to what. Is all this done inside my character blueprint or a new input action?

No worries,

You can do with single Input action or you can bind multiple actions (all single click but with different triggers)

However for the sake of the logic and previous post, I did with a single Input Action with additional enum to be tidy incase some one else also needs.

Input

Enum


Script

Edit:

You can also switch actions from the event like this if you want to keep same organisation (event driven)


Thank you so much for this! It is perfect! You have my utmost gratitude! This is some higher level knowledge for me. I haven’t even heard of enum before, I was doing some “add click/ reset count; gate; delay… “ spaghetti. I hope I can come to you in the future for more knowledge and problem solving.

1 Like

@RedGrimnir Any chance I could trouble you for a simple node line from the double click to be used to interact with an object? I was able to do it but only when I am next to the object, and I did it with sphere trace by channel, break hit result, does implement interface… and I tried increasing the sphere radius but it still required me to be next to it.

Also, how do you take a screenshot of the blueprint so that I can show you? My nvidia screenshot just creates a black screenshot.

Sure, win+shift+s or cmd+shift + s afaik to take ss,

You put here your code we take a look.

Also there is a node in unreal blueprints as

@RedGrimnir Here it is. When I turn on the debug on the sphere, I can see it overlaps the cube, but I need to stand next to it. The idea is that once I start the game, I can double click on the objects regardless of my distance, since it will just have to open doors, turn the lights on/ off and change a material or two. Also, the size of the objects will be clickable hitboxes. Aaaaaaand since the project is suppose to be used on PC and mobile, do I just need to add touch interaction and copy all the settings you gave for the mouse click in order for it to work?

I experimented with what you posted and succeeded. Thank you again. Now the question that remains is how to add the touch function to act the same as with this one click/ triple function? I saw there is an “get hit result under finger” so I should just use that instead of “under cursor”?

I understand, so simply

  1. You want a interaction with objects on the scene.
  2. Interactions is boundless from distance, visibility centered interaction.
  3. You want to use an interface for interactions (which is good)
  4. Target platforms PC and Mobile

You already integrated the click moderators, it should be working as demonstrated.

You have an interface

Integrated in your pawn and in your interactable units. I made a test unit like this, simply changing a material on a cube when interface message received.

On my pawn still same organisation , on double created a new function as TryInteract(). Additionally I show my cursor.

TryInteract() function as follows : 1st check objects under my cursor have interface
→ if (true) → call interface
→ if (false) → check same for finger and try interact.

Results

1

In your scripts you make line trace from actor to same actor position which simply will return nothing.

You can try doing like that, with simply

Normalize( GetActorLocation() ) * 500 + GetActorLocation()

and plug into the end of trace so that your trace starts from your actor center, goes 500 units in direction facing and returns if something is hit.

However its on Tick() which runs all the time, the way I show you is better since it will use tracing only when its double clicked meaning player meant to tryinteract()

Let us know.

UnrealEngine52025.12.17-20.39.22.01-ezgif.com-video-to-gif-converter

Wow, I am amazed how many methods there are to keep things organized, like that “try interact” function. This was an eye opener. Everything works flawlessly. Thank you!

1 Like

@RedGrimnir Following all the you shared, I was able to simplify my interaction even further and keep it organized. I abandoned the double click and stuck with only one click and hold. I wanted to post it here because I am really happy for all your help my friend. Also, if I did some unnecessary steps in my logic, please let me know. Thank you again.


1 Like

My pleasure, glad that it works and you can now make more design decisions on it matching your taste of gameplay aspects. There is nothing stands off and if something works, it just works no need to be too cautious about it.

Happy developing.

1 Like