- Home /
Box colliders, rigidbody -> Player and picked up cradle
Hi everyone,
in my game the character can pick up a cradle.
To do this, I have attached 2 box colliders to my cradle: One to prevent that the character walks through the cradle and one (slightly bigger) to work as a trigger (to detect if the player stands aside the box).
When the character picks up the cradle, I simply attach it to the player character.
My first approach was to simply attach the cradle to the player and that's it. The problem is that the cradle's box collider (the one preventing the player to walk through the cradle) intersects with the rigidbody of the player character and thus prevents the player character to move.
My second approach was to switch the box collider into a trigger, once the player has picked it up. Now, the player moves as expected, but unfortunately, the box disappears into a wall when the player character stands aside the wall.
My third approach was to disable the collision detection between the rigidbody.collider and the box collider (Physics.IgnoreCollision(rigidbody.collider, boxCollider, true). This seems to work since the player is able to move. But the box still disappears in the wall. I was hoping that the active box collider then would disable the player to walk close enough to the wall for the box to disappear in it.
The cradle does not have any rigidbody attached.
In my last attempt I removed the rigidbody from my player character and I only use the CharacterController to move my character and to handle collisions.
My questions:
Is this "double box collider" approach "the usual way" to handle this "player approaches object he wants to pick up" issue?
How can I prevent my player to do any collisions with the box but the box still prevents the player to approach the wall?
Thanks for your help. I'm really getting nuts on this. Isn't there anyone who had one of his characters carry a box or so ?
Best regards, Metron
Your answer
Follow this Question
Related Questions
CharacterController.Move becomes really slow after I move seperate colliders 1 Answer
Static collider vs Character controller? 1 Answer
How do I detect when two CharacterControllers collide? 0 Answers
Collider attached to a character controller doesn't work 3 Answers
w Key - Character Jumps 1 Answer