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.

1 Like

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: