问题
I have a player with a character controller, and a child object with a capsule collider extending a little bit out of the player's characterController to detect if the player jumps on a cube with a rigidbody on it. The child of the player has a tag called "hammer", and the rigidbody cube has a script on it.
For some reason, the child is not detecting collisions with the rigidbody. It only does so when the player and the child is touching the rigidbody. Here is the code for the rigidbody cube:
private void OnCollisionEnter(Collision other) {
if(other.collider.tag == "hammer") {
Destroy(gameObject);
}
}
NOTE: Can't add rigidbody to player otherwise spazzles out like spazzling is going out of style.
回答1:
Just needed to add rigidbody on the child and the tag, and didn't need the rigidbody on the external object.
来源:https://stackoverflow.com/questions/54876848/child-of-player-not-detecting-collision-with-rigidbody-on-other-object