- Home /
collision error
hey
i have a script that detects collisions and destroys the object. Now i know the script is fine, but it seems unity is having a problem with detecting collisions. when i smack into an object with a collider nothing happens, I then went to my scene view and used the arrows to force my character into the collider of the item to be destroyed, and it gets destroyed. The problem is as it seems that collisions wont work unless my colliders are a little bit inside each other. I have tried increasing and decreasing the sizes of both the colliders on the player and the object but it doesn't seem to work. If anyone has faced a similar problem or knows how to solve this let me know. Thanks
btw here is my script just so you can check it over just in case "
using UnityEngine; using System.Collections;
public class Item_pickup : MonoBehaviour {
void OnCollisionEnter(Collision collision){
if(collision.gameObject.name == "MainCharacter")
{Debug.Log("i will add an item into ur inventory on a random basis once programed");
//add code to generate a random drop based on items in game
Destroy(gameObject);}
}
}
Your answer