Hey guys,I am starting to learn more about unity.
Recently,I made a script that when you go into a trigger,another object activates/gets destroyed.
But I find that boring like you don’t even need to click the mouse.
So i need a script that when you click on a gameobject’s trigger or mesh,another gameobject appears.
Hopefully you can help me by finding a tutorial or a script!
In object A, have this script attached
var object : Transform;
var clicked = false;
function OnMouseEnter () {
clicked = true;
}
function Update () {
if(clicked){
object.GetComponent(OtherScript).activated = true;
}
}
then in the object you want to have activated, attach a script called ‘OtherScript’ which has the variable ‘activated’ in it
edcarlo
4
public GameObject otherObject;
void OnMouseUp() // mouse click
{
otherObject.SetActive(true);
}
void OnTriggerEnter() // for trigger
{
otherObject.SetActive(true);
}