When searching, I seem to only be able to find people who did not know to use the 2D version of colliders or methods, so it’s been difficult to find an answer for this.
I have two objects I want to collide (this game is a top view, so gravity does not come into play here).
When the fireball flies, it goes straight through the player without ever logging a collision. They are both on layer 0. Am I missing something small?
A Fireball:
(Note that I have IsTrigger checked, but either way does not seem to make a difference)
And the player (except for it’s transform, let me know if that is needed here):
Here is the code on the fireball:
var speed : int = 2;
function Update () {
transform.Translate( Vector3(.5,0,0) * Time.deltaTime * 10);
}
function OnCollisionEnter2D(coll: Collision2D) {
Debug.Log("FIREBALL COLLISION");
if (coll.gameObject.tag == "Player"){
coll.gameObject.SendMessage("ApplyDamage", 34);
}
Destroy(gameObject);
}
And here is the code on the player (though I don’t think the problem of 2D collision resides here):
var health = 100;
function ApplyDamage (damage : int) {
health -= damage;
if(health <= 0) {
Die();
}
}
function Die () {
//Die and or Respawn
Destroy(gameObject);
}