i have this minor problem which i just can solve, sadly enough. also sorry for my bad english…
i have a scene with a player (standard character controller). the player is parent of a camera by default. this camera is a parent to a sword i added to my scene. now when i hit play, the sword wont move pertaining to the camera.
now i added a box collider to the sword, and changed it into a trigger.
i also added a capsule to the scene which has a capsule collider by default, and gave it a rigidbody. i also added the following script to the capsule.
void OnTriggerEnter(Collider other)
print("i'm hit by a trigger!");
now when i hit start, and start swinging my sword (with the box trigger collider!) through my capsule, no message is given.
now my actual question is, how do i fix this?!
i work in C# by the way.
The problem does not come from the sword beeing a child but rather from the way it is moved. You can find a matrix of which kinds of collision get detected and send a message on the documentation.
I assume that your sword does not have a rigidbody. Therefor it is a static trigger collider. The capsule has a rigidbody therefor its collider counts as rigidbody collider.
According to the matrix this should work. But the capsule is not moving! Thus it does not need to check for collision on its side. The sword is static therefor it does not need to check for collision. It is like no one feels responsible for checking for collision.
Solution: The sword needs a rigidbody. Since you probably don’t want to move your sword through physics, you should make the rigidbody kinematic.
Also the OnTrigger function must be on the gameObject which has the trigger on it.