Stuck Bouncing Against Wall

app_sauceapp_sauce Member, PRO Posts: 206

I am making a game where a ball is bouncing against the walls in an enclosed square. And as soon as the ball gets fairly close to a wall and is moving relatively parallel to the wall it gets "stuck" almost grinding the wall, never to separate! It will just go back and forth on the same line. I want much more of a random bounce so this never happens. The balls movement is simple a timer that for .2 sec runs a accelerate towards code. I set a max high speed, turn bounciness up and have the balls collide with the wall tags. I know I need to change an attribute when the balls collide with the walls but not sure exactly what to change.

Thanks in advanced.

SocializeTwitter , **My Site ** **Play Loop Zen Free **iOS HERE, Google Play HERE

Comments

  • SocksSocks London, UK.Member Posts: 12,822

    @bktennis12 said:
    The balls movement is simple a timer that for .2 sec runs a accelerate towards code.

    Mysterious.

    @bktennis12 said:
    I set a max high speed, turn bounciness up and have the balls collide with the wall tags.

    Try reducing the friction for both actors to zero.

  • tintrantintran Member Posts: 453

    I wonder why the 0.2 timer for accelerate towards instead of just an accelerate toward without timer.

  • dustingriffiedustingriffie Member Posts: 57

    You need to change the acceleration to be relative to the actor not the scene, if the acceleration is facing 90 degrees relative to the scene, the ball will always be pushed up, whereas relative to actor it will change directions. I don't know how effective this will be as I have never done it but that seems to be your problem. Make sure fixed rotation is off too.

  • app_sauceapp_sauce Member, PRO Posts: 206

    @tintran The ball starts in the center has a short burst of acceleration in a random direction, then continues to bounce around the play area. When it hits a wall it changes direction until it hits another wall. If I always ran the accelerate toward code it would not change directions.

    SocializeTwitter , **My Site ** **Play Loop Zen Free **iOS HERE, Google Play HERE

  • dustingriffiedustingriffie Member Posts: 57

    I would also look into that if the ball hits the wall, change its direction. I will try to look into this as I have never done it.

Sign In or Register to comment.