No I'm using rigidbody with gravity, I should use kinematic ?
I have the exact same issue with arrows, they should disappear and send damage to the gameobject collided
When the ennemy is moving, it works fine, but when it's standing still it goes right thought it and doesn't trigger oncollisionenter
I tried using rigidbody + kinematic for all but it doesn't do much
EDIT : It seems like it works when using rigidbody without gravity or kinematic or gravity only
Arrow.cs : (moves the arrow, detects collision)
void Update () {
transform.Translate(new Vector3(0.01f,0,0));
}
void OnCollisionEnter(Collision col){
if(col.collider.CompareTag("Enemy")){
//col.gameObject.SendMessage("ChangeHealth", -archerScript.GetAttackPower());
Destroy(transform.gameObject);
}
}
Code to spawn an arrow :
public override void Attack(GameObject target){
if (curTarget != null && attackTimer >= attackDelay){
attackTimer = 0;
soundManager.SendMessage("PlayOnce", "meleeAttack");
tk2dSprite newArrow = Instantiate(arrow, new Vector3(transform.position.x, transform.position.y, 0), Quaternion.identity) as tk2dSprite;
}