- Home /
Object jumps out, when stuck between two colliders.
Hi there,
I´m currently building a pong clone in 2D and got a problem with my collisions, when the ball gets stuck between my racket and a wall.
Currently I got:
my racket with a box-Collider and a Rigidbody and a script for playercontrols
Walls with just a box-Collider
the ball itself with a box-Collider, a Rigidbod with PhysicsMaterial (bounciness=1, friction=0) and a movement/collision script - which basically just changes the direction on collision depending on where the ball hits the racket (hit on upper half - bounce ball back in top direction instead of normal collision as walls do, etc)
In general it works totally fine, collisions work as i expect them.
My Problem now is, that when i get the ball stuck between my wall and a Racket and continue my racket to move into the wall's direction (where the ball is stuck). I would want the racket to be blocked from moving any further (because there is the ball already, which cant move out of the way himself (because of that wall)) so that the ball can kind of slip through. while the ball shouldnt be blocking the racket's movement when it is not stuck in between something.
but what i currently get is:
the ball is pushed into the wall - and when there is not enough space for the ball anymore its pushed outside of the playfield (through the wall, kind of a short distance teleport^^)
Does someone have an Idea how to fix it?
Thanks for any help :)
Your answer