Object X and Object Y

Hey!

I’m trying to make a script that is attached to a 3D text (Because they don’t shrink on android phones) that will hide the 3D text until object X collides with object Y.

For example Object X is the Player, and then Object Y Runs into the Player. therefore making the 3D text appear saying “Retry” and when thats pressed the scene will restart.

I know i need to use isVisible = True; or a similar command, but i cant seem to figure out how to put this all into one script…

So if anyone could provide me with a rough draft of a script that can be attatched to the 3D text, and can still detect when object X and Y collide, so the 3D text appears

Any help would be appreciated!

-Fersuta

Hello. The way i would do this is i would have a trigger collider on one of the objects and check if an object has entered a trigger. Something like this

 void OnTriggerEnter(Collider col)
{
    if(col.gameObject.CompareTag("YourTag")
   {
         //execute code here
   }
}

This way you can attach a trigger to object X and check if an object Y has entered a trigger.

You can do that to check if a another colliders or rigidbody has entered a trigger. You can also do Collision decetcion using OnCollisionEnter.

Now to update your 3D text object , you can make a static method inside your text script , and call it from the trigget method.

 void OnTriggerEnter(Collider col)
{
    if(col.gameObject.CompareTag("YourTag")
   {
         MyTextScript.Show();
   }
}

And your text script would have this :

public static void Show()
{
      //make your object visible here
}

Tho the method i’d use includes events. If you’re not familiar with events read up on delegate methods and try to understand them.