- Home /
On Trigger Stay
Hey all. I have this script which allows my Player to read a piece of paper by clicking on the collider, however, they can click it from across the map. I want to add a, On Trigger Stay line that prevents them from clicking it from afar. Where would I add this? I've dealt with OnTriggerStay before, but I don't know how to implement it here.
Could you clarify what you mean by across the map? What type of view are we talking about? Top down, perspective, orthographic, ...
Answer by pgomes · Sep 18, 2014 at 12:26 AM
If I understand the question correctly, you want to select objects by clicking on them from a first person view. If so, I would use the Physics.Raycast function and check in the hitInfo if the hit was close enough.
Check this scripting reference example:
http://docs.unity3d.com/ScriptReference/Input-mousePosition.html
And the Physics.Raycast documentation:
http://docs.unity3d.com/ScriptReference/Physics.Raycast.html
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
How do i fix "Script does not exist" error when trying to add my script to something 3 Answers
Changing the renderer.material.color of the children OnCollisionEnter? 1 Answer
Healthbar Not Changing Size 2 Answers