Hello, I am running into a wall here and I would like help.
I have this empty parent game object that holds many children cube game objects that has colliders and another empty game object that has a collider of its own.
I want each of the respective children game object have their things called in the OnTriggerEnter because each children game object is supposed to cause an event in the game that I want it happen such as a dialogue box appearing.
However, it says I can’t have strings to compare if two gameobjects have collided with eachother and I would like people’s help if they could give me advise. Thanks in advance, I will continue to keep fiddling with this.
Here is the code I’m trying to work with:
public class Wave0TutorialEventManager : MonoBehaviour
{
public string collisionTagPlane = "PlayerPlane"; //The Player Plane Game Object
private GameObject cameraGUI; //The camera that will show all the text Boxes
private GameObject wave0TutorialEvent1;
private GameObject wave0TutorialEvent2;
void Start()
{
cameraGUI = GameObject.FindGameObjectWithTag ("TextBoxCamera");
wave0TutorialEvent1 = GameObject.Find ("Wave0TutorialEvent1");
wave0TutorialEvent2 = GameObject.Find ("Wave0TutorialEvent2");
}
void OnTriggerEnter(Collider col)
{
if(wave0TutorialEvent1 == collisionTagPlane)
{
cameraGUI.SendMessage ("Wave0TutorialEvent1", true);
Debug.Log ("Player Area has reached this point");
}
if(wave0TutorialEvent2 == collisionTagPlane)
{
cameraGUI.SendMessage ("Wave0TutorialEvent2", true);
Debug.Log ("Player Area has reached second point");
}
}
}
Anxo
2
Replace
if(wave0TutorialEvent1 == collisionTagPlane)
With
if(wave0TutorialEvent1.name == collisionTagPlane)
b/c what you are doing is (GameObject is equal to String?) but what you want to do is (StringA is equal to StringB?)