- Home /
Collision not working
Hey im making a GameObject wich gives you a cosmetic(The cosmetic part works fine) but when i try to pick the GameObject up/walk into it, it wont work. In the beggining it worked fine but then it just stopped. I have tried to read posts about it doesnt work. I have a game object called "GlassColor" with a rigidbody and a box collider without "is trigger" it also has the script. I have another game object called "Krop" and it has a rigidbody.
Heres the script:
public GameObject Con;
public GameObject me;
void Awake()
{
if (Glass.fg == 2)
{
Destroy(me);
}
}
void OnCollisionEnter(Collision collision)
{
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Krop")
{
Debug.Log("TAGET");
Glass.fg = 2;
PlayerPrefs.SetInt("fg", Glass.fg);
Con.SetActive(true);
Invoke("Return", 5.9f);
Destroy(me, 6);
}
}
void Return()
{
Con.SetActive(false);
}
}
Hope you know how to fix it. THX ;D
Answer by MT369MT · Jun 18, 2018 at 04:24 PM
Hi, the Krop should also have a BoxCollider. And is it normal that you have two OnCollisionEnter functions in your script?
Oh tanks. I Will try it as soon as Possible. And one of the OnCollisionEnter is not in the script
Your answer
Follow this Question
Related Questions
Object Collision PLEASE HELP!!! 1 Answer
Very simple collision death 1 Answer
Best collision detection method? 2 Answers
How do you execute Trigger-collider collision only in one gameobject? 1 Answer
Problem with Vectrosity line colliders 0 Answers