locojoetive

Rotating GameObject & Collider

Recommended Posts

Hello everybody,

I am new to Phaser and thought why not start with Phaser 3.

My program dynamically changes the rotation of a box and I wanted the collider to rotate as well, but I didn't find how to archive this.

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600, //window.innerHeight;
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 300 },
            debug: true
        }
    },
    scene: {
        preload: preload,
        create: create,
        update: update
    }
};

//...

function create() {
   //...
   blockAU = blocks.create(200, 200, 'block');
   //...
}

function update() {
   //...
   if(rotateLeft)
       blockAU.angle -= 1;
   else
       blockAU.angle += 1;
   
   blockAU.refreshBody();
   //...
}

I didn't find examples for this, and the API and Docs where pretty confusing. Maybe I am using the wrong terminology when searching.

I really hope you can help me with this :)

 

ColNotRot.jpg

Share this post


Link to post
Share on other sites

Hello samme,

Thank you for your fast reply. I replaced block.angle with block.rotation, but get the same results. The link you posted about the rotation of a body says:

" It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle."

Does this mean it isn't possible to rotate a rectangular body with the Arcade Physics?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.