My models in this my game aren’t sensing a collision with each other when they spawn (if they spawn inside each other), causing a script I made (to fix the issue of spawning inside another model) to not do anything. Here is the script and a picture of the models inside each other:
using UnityEngine;
using System.Collections;
public class CollisionCheck : MonoBehaviour {
void OnCollisionEnter(Collision col)
{
print("CollisionEnter");
if (col.gameObject.name != "Player" && col.gameObject.name != "Ground")
{
GameObject.Find("GameController").GetComponent<CreateBuildings>().Spawn(gameObject);
print("Called");
Destroy(gameObject);
}
}
void OnCollisionStay(Collision col)
{
print("CollisionStay");
if (col.gameObject.name != "Player" && col.gameObject.name != "Ground")
{
GameObject.Find("GameController").GetComponent<CreateBuildings>().Spawn(gameObject);
print("Called");
Destroy(gameObject);
}
}
}
Does anyone know have an idea on what is causing this?