- Home /
GameObject B does not collide with GameObject A
Hello guys,
I have a 2D game where A attacks B and then B attacks A (turn-based). A attacking B works fine, but B attacking A has issues - read the issue part for explanation.
MY ISSUE:
GameObject A
walks towards GameObject
B
. It collided with B normally and performs action OnTriggerEnter
. Now the same thing should occur with GameObject B
. GameObject B
walks towards GameObject A
. It DOES NOT collide where the actual boundaries of BOX COLLIDER are (both use two Box Colliders,
one for actual collision, other one for IsTrigger
events). But it stops in the middle of GameObject
A
, crashing to it for few times and stops.
BoxCollider
boundaries are set OK. Even if I make them bigger, the first scenario (A -> B) works as expected (will stop even sooner, because of bigger collider on B), but vice versa (B -> A) won't work and same scenario happens (B will walk to center of A and keep hitting to that point few times and stop).
SCENARIO:
I don't know what I am doing wrong. I think I might be missing something related to 2D Physics of using BoxColliders.
Could you post your code for the two GameObjects please, I think I had the same issue in the past @$$anonymous$$92
You have 2 separate gameobjects for each collider object, and a separate script to handle each, correct?
Answer by damiano201 · May 22, 2017 at 07:33 AM
Are you using Rigidbody2D? I believe this component should be added to both objects. It looks like your issue might occur because Game Object B doesn't have Rigidbody2D.
Your answer
Follow this Question
Related Questions
Moving a player smoothly without breaking collisions? 2 Answers
Make characters go through each other 1 Answer
Smooth Collisions 2D 0 Answers
No Collision in 2d Scene 0 Answers