Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two way collision between circles, with arcade physics #4256

Closed
JeSuisUnCaillou opened this issue Dec 24, 2018 · 1 comment
Closed

Two way collision between circles, with arcade physics #4256

JeSuisUnCaillou opened this issue Dec 24, 2018 · 1 comment

Comments

@JeSuisUnCaillou
Copy link

JeSuisUnCaillou commented Dec 24, 2018

Version

  • Phaser Version: 3.15.1
  • Operating system: Windows 10
  • Browser: Not specific.

Description

This concerns the arcade physics engine.

If you have two Circles colliding "sideways" while both having a velocity, the bounce will be extremely weird, like if they are "bouncing back".

Example Test Code

This code is almost exactly the same than this example : http://labs.phaser.io/view.html?src=src\physics\arcade\circular%20body.js&v=3.15.1

I just changed the initial velocities to make them do the weird collide bug.

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'phaser-example',
    physics: {
        default: 'arcade',
        arcade: {
            debug: true,
            gravity: { y: 100 }
        }
    },
    scene: {
        preload: preload,
        create: create
    }
};

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('wizball', 'assets/sprites/wizball.png');
}

function create ()
{
    var ball1 = this.physics.add.image(100, 240, 'wizball');
    var ball2 = this.physics.add.image(700, 240, 'wizball');

    ball1.setCircle(46);
    ball2.setCircle(46);

    ball1.setCollideWorldBounds(true);
    ball2.setCollideWorldBounds(true);

    ball1.setBounce(1);
    ball2.setBounce(1);

    // here are the changed velocities 
    ball1.setVelocity(150, 0);
    ball2.setVelocity(-150, 0);

    this.physics.add.collider(ball1, ball2);
}

Additional Information

I'm currently building a game of "bumper ships", where the collisions should work like a billard game. This weird bounce is the only thing that is holding me back.

Billard games are very common, and I wonder if anyone has tried to make one with the arcade physics engine. If you did, I'll be glad to hear how you managed the collisions.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants