Problem with OnCollisionEnter
Hi! I`m trying to catch the moment when my enemy prefab get attached on a fence (tag = "Colisiones"), with a Box Collider 2D. My Enemy has a collider too (circle collider 2d) and a rigid body 2d, so the code it`s on his script
void OnCollisionEnter(Collision col) {
if (col.gameObject.tag == "Colisiones") {
onCol = true;
}
There are the options of my Enemy Rigidbody:
Do you see anything? Thanks!!
Answer by Nullmind · Jul 27, 2017 at 10:17 PM
You have checked "Is Trigger" on your enemy collider, do you?
No no, becouse i want to my enemy hits the fence, not through it. I forgot to say that this code is only a test to comprobe the method OnCollisionEnter. The problem is that this parameter "onCol" (false at the beggining of the class) dont change to "true" when the enemy hits the collider of the fence.
Answer by Exiverse · Jul 28, 2017 at 01:53 PM
I forgot to say that this code is only a test to comprobe the method OnCollisionEnter. The problem is that this parameter "onCol" (false at the beggining of the class) dont change to "true" when the enemy hits the collider of the fence.
Can you guys know what's the problem?
Oh, and the colliders dont have checked "Is trigger"
Your answer
Follow this Question
Related Questions
How can i optimize colliders in my character? ( character stuck) 0 Answers
My collision is not being detected or does not produce the desired outcome. 2 Answers
Unity2d move enemy in opposite direction on collision 1 Answer
2D collision not working 0 Answers
Can't get Collision to detect triggers in unity 2d 4 Answers