1

I don't have the source code right now, I will try to explain my error:

I created a multidimensional Array of GameObject, for each GameObject I created a primitive cube, added a script component containing a class with a boolean attribute with relative set/get method, set his attribute to true and moved the transform.

Then in my Update() function I want to get the value of the attribute of the clicked GameObject.

The script is working but I get FALSE instead of TRUE.

For Debug I put a Destroy(hit.trasform.gameObject) and the GameObject is destroyed, but still log FALSE instead of true.

Is it something wrong with the procedure? I have forgot something?

If isn't clear I will upload the code later when I have access!

2
  • what method you use for accessing that gameObject that you hit Commented Nov 6, 2014 at 14:26
  • hit.transform.gameObject.GetComponent<Tile>().getBoolean(); Commented Nov 6, 2014 at 14:34

1 Answer 1

0

Create a function inside the Tile:

public void setBoolean(bool b)
{
    yourBool = b;
    Debug.Log("Printing the boolean value: " + yourBool);
}

Then in your collision code:

hit.transform.gameObject.SendMessage("setBoolean", true);

Or if you prefer:

hit.transform.gameObject.GetComponent<Tile>().setBoolean(true); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.