Hi!
I want to add a chest and allow the player open it only when it is in front of it.
How can I do it?
With Raycast?
Thank you!
Hi!
I want to add a chest and allow the player open it only when it is in front of it.
How can I do it?
With Raycast?
Thank you!
Two main ways
1 Overlap volume on the chest. When the player overlaps, the chest enables input, and the player can interact
2 Raytrace and an interface. The player fires a ray at the chest and says ‘I’m interacting with you’
I like this one. I have found this to know how to do it: Using a Single Line Trace (Raycast) by Channel in Unreal Engine | Unreal Engine 5.7 Documentation | Epic Developer Community
Thanks!
Ray is better. Trouble with the overlap method, is you can also interact with the object using your butt ![]()
(post deleted by author)
I’ve done this:
But I can interact with the chest from all of its four sides.
How can I do it only when the player is in front of it?
Thank you!
Hello,
Something like this should do the trick.
You can adjust the value on == if required, but I found this value good enough, so you can also open a chest when looking at it from an angle.
Important: Make sure your chest meshes are rotated properly. In order to double check which way is forward, select the root of your chest and add arrow component, whichever way it’s pointing, that’s forward direction. For testing, I would also uncheck “hidden in game” on arrow component.