- Home /
Keeping an object inside a box collider, bouncing it back when it tries to exit
Hello, I'm making a marble-arena style game, where player marbles can be bounced out of the arena. however, I would like certain other objects to be bounced back when they hit the boundaries. I found solutions that recommended setting up a box collider on each side of the arena, but at some point I would like the arena to be a dynamically changing polygon, or a circle.
I have a prefab representing the arena, Tile. What I've done so far is given Tile an empty child gameObject which has a collider that encompasses the volume of Tile plus height enough to encompass objects on top of Tile. It inhabits its own layer, such that collisions between the Player are ignored, but collisions between it and objects of interest are processed. Therefore, OnCollisionExit triggers when objects of interest leave the arena. From this, is there a way to make the objects bounce back using this collider?
Thank you for reading
Your answer
Follow this Question
Related Questions
how to stop mesh entering another mesh, both with colliders 3 Answers
Attaching multiple rigidbodies together and spawnning as prefabs 1 Answer
RaycastHit Collider Question 1 Answer
Mass / Collider Sizes 1 Answer
UnitySteer, ground and stairways 0 Answers