- Home /
Counting colliders
Hello, is there a way to count how many colliders are colliding my object at the same time??
The problem is:
I have a character and he can pick up rigidbodies when it touchs one and I press a button but the only way I have to avoid it pick 2 objects at same time is to make the collider small but there is always a chance to pick more than one at once, so is there a way to deny he pickup any objects if there are more than one collider collidiying?
Thanks!
Answer by Loius · Jan 07, 2011 at 06:45 PM
Use
if ( !playerHoldingItem ) {
PickUpItem();
} else {
// don't pick up item, he's already got one
}
That's all pseudocode of course. Just have a check to say you can only hold one item at once.
If you do need to know how many are colliding, in each OnCollisionEnter (or TriggerEnter) increment a variable on the player; then in Exit, decrement that variable.
Answer by raed · Jan 07, 2011 at 06:12 PM
the proplem not with collider because u cant add 2 collider at same time try it the proplem might be in script or ( adding the same script to multiple object ) try to chick your script
Your answer
Follow this Question
Related Questions
Picking up items with Rigidbodies 2 Answers
Collision Problem 1 Answer
Collisions don't work properly 1 Answer
collision child with rigidbody in parent 0 Answers