Page 1 of 1

Find an Interactable Target in front of Player Object

Posted: Thu May 24, 2018 7:58 pm
by TragicManner
I want to set up a simple system where the player faces towards an object that they want to interact with, and if it has dialogue, it will trigger that dialogue when the interact button is pressed.

I tried using the Selector setup, but for some reason it seems to only work when the object is directly above the player object. Any insight in how to simply look directly in front of where the player is facing for a certain range and interact with that object?

Re: Find an Interactable Target in front of Player Object

Posted: Thu May 24, 2018 9:24 pm
by Tony Li
Hi,

Add a Proximity Selector and a trigger collider to the player GameObject. Position the trigger collider in front of the player.

Add a regular collider, a Usable component, and a Conversation Trigger (or Dialogue System Trigger) to the NPC.

If that doesn't do the trick, please let me know whether this is 2D or 3D, and the camera perspective (e.g., 2D topdown, 2D platformer, 3D over the shoulder, etc.).

Re: Find an Interactable Target in front of Player Object

Posted: Thu May 24, 2018 10:55 pm
by TragicManner
Great, that worked perfectly, thanks!

This was for a fixed camera in a 3D environment, with an isometric-style camera angle, in case someone needs that for reference.

Re: Find an Interactable Target in front of Player Object

Posted: Fri May 25, 2018 8:53 am
by Tony Li
Glad to help!