Reputation: 1
Well, I have a gameobject that is a trigger called Object A.
I want to know how to find out if the trigger was clicked. if I do
void Update()
{
if( Input.GetMouseButton(0))
{
runthefunction();
}
}
then it just waits for me to click anywhere.
I want the runthefunction()
function to run when I click on ObjectA (the trigger).
Upvotes: 0
Views: 62
Reputation: 2472
If you are using a trigger, use the function OnTriggerEnter()
void OnTriggerEnter()
{
runthefunction();
}
See here for more info: http://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
Upvotes: 1