- Home /
How to check if a BoxCollider is hit by a trigger?
I searched everywhere I could not find the answer. My problem is that I have a Sword attached to my player. If the sword isn't a trigger the player "glitches out". So if the collider of my sword hits a Zombie, it looses health but if trigger is enabled it doesn't. The script attached to the Zombie checks if there is a collision with "Sword" but it isn't triggered when the collider of sword is a trigger. Both objects have rigidbodies. So is there a way to check if a BoxCollider (trigger not enabled) is hit by another BoxCollider (trigger enabled) and not the other way around?
Answer by Burla · Apr 26, 2014 at 08:15 PM
Well you should be able to use the OnTriggerEnter() function on the GameObject that has a BoxCollider that isn't a Trigger.
void OnTriggerEnter(Collider other) {
// Lose HP
// Play sound
// Do whatever you like
}
Your answer
Follow this Question
Related Questions
Access other collider without use of Trigger collider. 1 Answer
Box collider triggers interfering with rigidbody movement 3 Answers
Trigger Collision with Character Controller 0 Answers
How to get collision point when using onTriggerEnter 5 Answers
Use OnTriggerEnter() without Rigid Body or Collider 1 Answer