Hello folks,
Im almost giving up with this I cant figure out what more to do.
I did tried many combinations of scripts with no luck
My problem is that Im having problem by destroying an auto generated building to have it replace with my custom mesh.
In Screenshot-1 you can see that the auto generated building has no name, is in a Building Layer and has an Mesh Collider on it.
On Screenshot-2 you can see that my custom mesh has also an auto generated name, a Box Collider and my ObjectCollisionDestroy c# script.
WHAT DO I NEED TO DO TO HAVE THIS WORKING??
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectCollisionDestroy : MonoBehaviour {
//Detect collisions between the GameObjects with Colliders attached
void OnCollisionEnter(Collision collision)
{
Debug.Log(collision.gameObject + " Touched a Building!");
Destroy(collision.gameObject);
//Check for a match with the specified name on any GameObject that collides with your GameObject
/*
if (collision.gameObject.name == "MyGameObjectName")
{
//If the GameObject's name matches the one you suggest, output this message in the console
Debug.Log("Do something here");
}
*/
//Check for a match with the specific tag on any GameObject that collides with your GameObject
/*
if (collision.gameObject.tag == "POI")
{
//If the GameObject has the same tag as specified, output this message in the console
Debug.Log("If the GameObject has the same tag as specified, output this message in the console");
}
*/
/*
if (collision.gameObject.layer == LayerMask.NameToLayer("Buildings"))
{
Debug.Log("Touched a Building!");
//Debug.Log(LayerMask.NameToLayer("Layer_Name"));
}
*/
}
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}