Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

I have created a game object (Brick) and added a script (BrickScript) to it. Within this script I create a Window game object if a certain condition is satisfied. Please see code below:

if (hasWindow) {
 
        if (window == null) {
        var size = gameObject.GetComponent<SpriteRenderer>().bounds.size;
        window = (GameObject)Instantiate (Resources.Load ("Prefabs/OtherPrefabs/Window"), 
                    new Vector3 (transform.position.x + 0.5 * gameObject.GetComponent<SpriteRenderer> ().bounds.size.x,
                        transform.position.y + 0.5f*gameObject.GetComponent<SpriteRenderer>().bounds.5f * size.y, transform.position.z), 
                    Quaternion    transform.Identity)position.z);, 
            Quaternion.Identity));
        window.name = gameObject.name + "Window";
            }
}
 

 

The Brick and window game objects actually overlap a bit. I realized that when hasWindow = true (the window is created) the condition in the code below is not satisfied and other game objects don't collide with the Brick. But when hasWindow = false (the window is not created), everything seems to work well. How can I solve this?

void OnMouseDown    ()  {
    
    if (Input.GetMouseButtonDown(0)) {
 
        Debug.Log ("touch down");
        hasBeenTouched = true;
    }
}

I have created a game object (Brick) and added a script (BrickScript) to it. Within this script I create a Window game object if a certain condition is satisfied. Please see code below:

if (hasWindow) {
 
        if (window == null) {
                window = (GameObject)Instantiate (Resources.Load ("Prefabs/OtherPrefabs/Window"), 
                    new Vector3 (transform.position.x + 0.5 * gameObject.GetComponent<SpriteRenderer> ().bounds.size.x, transform.position.y + 0.5f*gameObject.GetComponent<SpriteRenderer>().bounds.size.y, transform.position.z), 
                    Quaternion.Identity));
                window.name = gameObject.name + "Window";
            }

The Brick and window game objects actually overlap a bit. I realized that when hasWindow = true (the window is created) the condition in the code below is not satisfied and other game objects don't collide with the Brick. But when hasWindow = false (the window is not created), everything seems to work well. How can I solve this?

void OnMouseDown    ()  {
    
    if (Input.GetMouseButtonDown(0)) {
 
        Debug.Log ("touch down");
        hasBeenTouched = true;
    }
}

I have created a game object (Brick) and added a script (BrickScript) to it. Within this script I create a Window game object if a certain condition is satisfied. Please see code below:

if (hasWindow) {
    if (window == null) {
        var size = gameObject.GetComponent<SpriteRenderer>().bounds.size;
        window = (GameObject)Instantiate (Resources.Load ("Prefabs/OtherPrefabs/Window"), 
            new Vector3 (transform.position.x + 0.5 * size.x,
                        transform.position.y + 0.5f * size.y, 
                        transform.position.z), 
            Quaternion.Identity));
        window.name = gameObject.name + "Window";
    }
}
 

 

The Brick and window game objects actually overlap a bit. I realized that when hasWindow = true (the window is created) the condition in the code below is not satisfied and other game objects don't collide with the Brick. But when hasWindow = false (the window is not created), everything seems to work well. How can I solve this?

void OnMouseDown () {
    if (Input.GetMouseButtonDown(0)) {
        Debug.Log ("touch down");
        hasBeenTouched = true;
    }
}
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user