C
C#2y ago
Nos_E3ks

❔ trying to get my Dialog system to be with a key press and not just walking into the npc, unity 2d

I've been trying for awhile now to make it so it works but, everything I do doesn't work. I have all the code, it works but when you walk into the npc, and I want to figure out how to do it when I walk up to the npc and press the Z key at the same time. thank you
3 Replies
Angius
Angius2y ago
Don't start conversation on collision, then Two ways I used to add interaction on key press in Unreal, something similar should be doable in Unity as well: 1. On key press, sphere cast towards the camera, get a reference to the hit object, check if it implements an IInteractable inteface, if so proceed with dialogue 2. Spherical or capsule collider around every interactable object, perhaps abstracted to a component. On key press check all interactable colliders The first method is, IMHO, better. Lets you pack interactable objects closer together, and the player has more precision when picking what they want to interact with
Nos_E3ks
Nos_E3ksOP2y ago
alright that is true, just need to figure out how to set that up! I still quite neww to coding, thats why i asked lol,
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server