- Home /
Collider only works as a child object
Hello, first time posting here. Any help would be greatly appreciated. I am making a simple 3d game with a temple runner style camera.
I have a collider which needs to detect when an obstacle is passed by the player and add points to the score total. It works fine when it is attached as a child to the main player object. However, it messes up the collision detection with the other player colliders (allowing him to jump multiple times without touching the ground). So, I need to separate it. But, when I make it a separate object it no longer detects the collisions with the obstacles :(
The collider has it's own tag "scoreCollider" and it has "is trigger" checked. When I separate it from the player it no longer detects the collisions with the obstacles which also have "is trigger" checked.
I thought the problem was that the score collider was already colliding with the player, so I moved the collider back to a point where it is not colliding with anything but it fails to activate OnTriggerEnter() when it passes the obstacles.
I am very confused because as I mentioned the collider works perfectly when it is a child of the player object.
Please help!
Answer by Kiwasi · Jul 01, 2014 at 08:06 AM
Colliders need to be on a GameObject with a RigidBody, or a child of a GameObjet with a RigidBody in order to cause trigger events.
Hope that helps.
Bored$$anonymous$$ormon are you sure? cos I'm using box Colliders and what not without rigid bodies attached and it works fine.
I wouldn't use just a box collider however if I wanted the gameobject to move $$anonymous$$d, but you can defo use just a collider with no rigidbody. Because I'm doing it :P
$$anonymous$$y original thought to this issue was that the original gameobject is off randomly in the scene, and then the child (of which is a gameobject is at another position) so the box when attached to the parent is off at one location, and attaching to the child is at the right position.
If you do not attach rigidbodies, you can not receive Collisions and Triggers, but you can use Raycasting only.
At least one collider in a collision must be associated with a rigid body to fire. Any other behaviour is a bug.
Your answer
Follow this Question
Related Questions
Rotated child's geometry changed when attach to parent 1 Answer
boost and hit the edge of a collider and you go backwards 0 Answers
Colliders on this spider 1 Answer
RaycastHit2D hits "itself" 3 Answers