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() {
       blockAU.angle -= 1;
       blockAU.angle += 1;

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 :)



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

hm ...

probably not how it's done as i never 'learned' anything but by myself so i tend to go with my way and what works :


this.spikes = this.physics.add.staticGroup();
        tmp = leveldata[6].split('-');
        for(let lus=0;lus<tmp.length;lus++){
            let spikedat = tmp[lus].split(':');
            let spikerot = spikedat[1];
            let spikepos = spikedat[0].split(',');
            console.log(typeof spikerot);
            case '0':
            case '2':
            this.spikes.create(spikepos[0],spikepos[1], 'spikes').setSize(50,34).setOffset(10,0).setAngle(spikerot*90);
            case '1':
            case '3':
            this.spikes.create(spikepos[0],spikepos[1], 'spikes').setSize(34,50).setOffset(20,-10).setAngle(spikerot*90);//body.rotation not working or im doing it wrong


screenshot :

screenshot of scene ingame (OGA1 : Oga is the new Crack : get things moving) #opengameart

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.