- Home /
Question by
EClancy · Dec 10, 2014 at 09:16 AM ·
2djavascriptcollisiongameobjectcollider
Unity 2D Colliders not Colliding
I have a ring of fire that I would like to melt ice on the ground. The colliders just don't seem to register each other. Why won't the colliders work? (They successfully register the player)
Here's the scene with the ice patch's collider
And here's the scene with the ring of fire's collider
Here are the objects in the Hierarchy
And here is the Javascript on the ringOfFire
var burnDuration = 6.0;
var damagePerTick = 3.0;
function OnTriggerStay2D( coll : Collider2D) {
Debug.Log(coll.gameObject.name);
if (coll.gameObject.transform.root.tag == "Player"){
var args = new Array ();
args.Push (burnDuration);
args.Push (damagePerTick);
coll.transform.root.SendMessage("setFire", args);
}
if (coll.gameObject.name == "icePatch(Clone)"){
Destroy(coll.gameObject);
Debug.Log("Melted Ice");
}
}
Comment
Best Answer
Answer by EClancy · Dec 11, 2014 at 01:03 AM
I figured it out so I'll post it here - turns out edge colliders cannot collide with each other. I used polygon colliders instead, and this solved my problem.
Answer by HarshadK · Dec 10, 2014 at 07:00 AM
Put a Rigidbody2D component on your ringOfFire game object.
I've now added this to both objects, but I see no results.