- Home /
Duplicate Question
Box collider doesnt detect collision
I have a sword(which i made in blender, and an animation) and i got a box collider on it with is Trigger marked. And a script attached to it. When it's colliding with enemy(which i also made in blender) it doesn't destroy it. Please help. using UnityEngine; using System.Collections;
public class Sliced : MonoBehaviour {
// Use this for initialization
void Start () {
}
void OnCollisionEnter(Collision col) {
if (col.gameObject.tag == "Enemy") {
Destroy(col.gameObject);
Debug.Log(col);
}
}
}
FRO$$anonymous$$ THE $$anonymous$$ANUAL(pay attention to the method triggers should use):
Triggers
The scripting system can detect when collisions occur and initiate actions using the OnCollisionEnter function. However, you can also use the physics engine simply to detect when one collider enters the space of another without creating a collision. A collider configured as a Trigger (using the Is Trigger property) does not behave as a solid object and will simply allow other colliders to pass through. When a collider enters its space, a trigger will call the OnTriggerEnter function on the trigger object’s scripts.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Minecraft Bedrock help 3 Answers
1stPersonController bigger than World. HELP PLS :( 3 Answers
Temple run game 1 Answer