- Home /
How to add sign interaction?
I want the player to be able to interact with signs in game. So, when the character moves in front of the sign, I want a small section of text to appear above the sign saying
'press 'e' to interact'
Once the player has pressed 'e' (while still in front of the sign), I need three sprites to pop up, the sign background, the sign text and a small back arrow. When the arrow is clicked, or the 'escape' key is pressed, the sprites need to disappear again.
Answer by eskivor · Aug 13, 2017 at 10:43 AM
what have you already tried ?
Nothing yet, I'm new to unity and don't quite know how to do stuff. I tried a bunch of online tutorials, but they were all out of date and didn't work.
quick answer : - use triggers to check if you're in front your sign or not - create ui elements for your text - add a script on your trigger with the OnTriggerEnter method, and activates a boolean variable for the next step - in an update on a script in the scene, add a if conditioner to check the input used (Input.Get$$anonymous$$eyDown or Input.GetButtonDown) - assign your ui elements in your script - activate or desativate your ui elements with the gameObject.SetActive method
Thanks for your quick reply, can I have an example script?