Jump to content

Change of direction not working as expected


freetoplay
 Share

Recommended Posts

I have a ball that is 26x26 and I am trying to make it change direction when it collides with an object.

My code looks something like this:

let collideP1 = game.physics.arcade.collide(ball, p1);

if (collideP1) {

ball.body.velocity.x = -ball.body.velocity.x;

}

This code gets called in the update() method. However when a ball hits a rectangular object, the movement stops. How do I properly get it to change direction? Please let me know if I need to add more code.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...