Download

Detect touch on Actor

Hello world!
In blueprints we have OnClick/OnTouchBegin events witch is triggered when touch occur on target actor.
How we can accomplish this in C++?

I did a few projects where it was done this way:

  • all “InteractiveObjects” implement an interface with OnMouseOver(), OnMouseOff(), OnMouseClick() etc. events
  • every Tick() cast a ray for actors/components and cast whatever got hit to InteractiveObject interface
  • if the mouse is down and it is hitting an InteractiveObject then fire the mouse event on that actor or component

Thanks Jocko.
But i think that performing raycast each frame can result to perfomance hit.

A sphere component with overlap events?