How to interact with objects by clicking on them in a topdown?

Probably a very basic issue, forgive my lack of knowledge.

The game is a topdown shooter, character aims at cursor and shoots with left click. The player must be able to interact with basic interactible objects like lights, doors, elevators etc, just right click on it and it will change it’s situation, in light example it will open and close, in elevator example it will go up and down etc. As I imagined all interactible objects will have only 2 mods so must be easier.

Also what will decide if the object is not is simply the range, this is probably the most simple part.
Mabe I am thinking wrong, never done this before, thank y’all in advance.

Hi there,

In your controller should be already integrated Mouse Event (Click, Touch) just search details for mouse. There should be also trace channel for it and distance.

Simply on the actors you want to interact, on collision component ->OnHit you can catch events like click hover etc. Think this was hardcoded into an input (old input system if I remember correctly however its possible to override from C++). This would be the most easy shortcut.

If you want to push it further. Simply you can make a trace from your mouse cursor with controller->GetObjectsUnderController and interact with them better with an interface. This function is generally built in the base class of player controller for you to use.

Further more besides these 2 solutions if you want to be really deterministic and full control over your interaction system then you can make your own system with blueprints without going too deep to test if you want more control of how it behaves.

WorldMousePos = DeProjectScreenToWorld(CursorPosition)

MultiLineTrace( WorldMousePos + OffsetZ, WorldMousePos - OffsetZ) ->HitResults->Actor->DoesImplementsInterface->CallInterfaceMessage->OnInteracted

Actor(Interacted)-> DoWhatever

This would give you scanner to interacted communication with a decent architecture for the further development stages.

Let me know and happy developing.

This is actually a very common system in top-down games, and your idea is already on the right track :+1:

A simple way to approach it in Unreal Engine:

  1. Detect what the player is clicking
  • On right mouse click, do a Line Trace (Raycast) from the camera to the mouse cursor.

  • Use Get Hit Result Under Cursor (very useful for top-down games).

  • This will tell you what object the player clicked on.

  1. Check if the object is interactable
  • Create a base Interactable Blueprint (or Interface).

  • Any object (door, light, elevator) implements this.

  • When the trace hits something, check:
    → Does it implement your Interactable interface?

  1. Check interaction range
  • Get distance between player and hit object.

  • If distance ≤ your interaction range → allow interaction.

  • Otherwise ignore.

  1. Trigger interaction
  • Call a function like Interact() on the object.

  • Inside each object:

    • Use a simple boolean (e.g. IsActive / IsOpen).

    • Flip it (true ↔ false) each time player interacts.

    • Then play the corresponding behavior:

      • Light → turn on/off

      • Door → open/close

      • Elevator → go up/down

  1. Optional improvement (recommended)
  • Use an Interface instead of casting (cleaner and scalable).

  • Add a highlight effect when hovering over interactable objects.

So the basic flow is:
Right Click → Line Trace → Check Interactable → Check Distance → Call Interact()

Your “2 modes only” idea is perfect for starting. You can always expand later (locked doors, multi-state elevators, etc.).

You’re definitely thinking in the right direction :+1:

the piece the earlier answers skipped is separating the two click paths so shooting never fights interaction:

dedicated trace channel: create a custom trace channel, interactable, default response ignore everything except your interactable actors (lights, doors, elevators set block on it). now left click shooting and aiming use the visibility channel as usual, and interaction queries cannot be eaten by walls or the ground.

right click flow: enhanced input action IA_Interact bound to right mouse button, on triggered run get hit result under cursor by channel with the interactable channel, cast the hit actor to a blueprint interface, BPI_Interact with a single interact function, call it. each object type implements the interface its own way, light toggles, elevator moves.

hover prompt, optional but makes it feel finished: on a 0.1 second throttled tick, same trace, if it hits an interactable show a small prompt widget at the projected screen position naming it, hide when the trace misses. same channel means the prompt can never point at something the click will miss.

this click detection and interface call loop is exactly what the Hidden Object Game Template implements for click to find, a data driven hidden object game template for unreal engine 5 with the cursor trace, the per object response and the feedback ui commented end to end if you want a working reference to read: Multiplayer Hidden Object Game Template | Fab