Collision in the circuit

Hello I want try make collision between car and circuit (inside) but I don’t how, so have you some tips please?
image

let x=500;

let y =500;

let f_car =0;

class Example extends Phaser.Scene

{

constructor ()

{

    super();

}

preload ()

{

    this.load.spritesheet("f1_car","assets/car_spritesheet0.png",{frameWidth:98,frameHeight:72});

    this.load.setPath('assets_racing/racing/');

   

    this.load.obj('roadStart', 'roadStartPositions.obj', 'roadStartPositions.mtl');

 

    this.load.obj('roadStraight', 'roadStraight.obj', 'roadStraight.mtl');

 

    this.load.obj('roadCornerLarge', 'roadCornerLarge.obj', 'roadCornerLarge.mtl');

    this.load.obj('roadCornerLargeBorder', 'roadCornerLargeBorder.obj', 'roadCornerLargeBorder.mtl');

   

}

create ()

{

    const track = this.add.mesh(400, 300);

    const rot90 = Phaser.Math.DegToRad(90);

    const rot180 = Phaser.Math.DegToRad(180);

    const rot0 =Phaser.Math.DegToRad(0);

    f_car = this.physics.add.sprite(x,y,"f1_car");

   

    //  Add road pieces

    track.addVerticesFromObj('roadStart', 1, 0, 0, 0, rot90, rot180);

    track.addVerticesFromObj('roadStraight', 1, 0, 2, 0, rot90, rot180);

    track.addVerticesFromObj('roadCornerLarge', 1, 0, 3, 0, rot90, rot180);

    track.addVerticesFromObj('roadCornerLargeBorder', 1, 0, 3, 0, rot90, rot180);

    track.addVerticesFromObj('roadStraight', 1, 2, 5, 0, rot90, rot90);

    track.addVerticesFromObj('roadStraight', 1, 3, 5, 0, rot90, rot90);

    track.addVerticesFromObj('roadCornerLarge', 1, 4, 5, 0, rot90, rot90);

    track.addVerticesFromObj('roadCornerLargeBorder', 1, 4, 5, 0, rot90, rot90);

    track.addVerticesFromObj('roadStraight', 1, 5, 2, 0, rot90, rot180);

    track.addVerticesFromObj('roadStraight', 1, 5, 1, 0, rot90, rot180);

    track.addVerticesFromObj('roadStraight', 1, 5, 0, 0, rot90, rot180);

    track.addVerticesFromObj('roadCornerLarge', 1, 6, 0, 0, rot90, rot0);

    track.addVerticesFromObj('roadCornerLargeBorder', 1, 6, 0, 0, rot90, rot0);

    track.addVerticesFromObj('roadStraight', 1, 3, -1, 0, rot90, rot90);

    track.addVerticesFromObj('roadStraight', 1, 2, -1, 0, rot90, rot90);

    track.addVerticesFromObj('roadCornerLarge', 1, 2, -2, 0, rot90, rot180+rot90);

    track.addVerticesFromObj('roadCornerLargeBorder', 1, 2, -2, 0, rot90, rot180+rot90);

    //  Zoom the camera

    track.panX(-5);

    track.panY(7);

    track.panZ(50);

    this.debug = this.add.graphics();



    const rotateRate = 1;

    const panRate = 1;

    const zoomRate = 4;

    this.track = track;

   

}

update ()

{  



    this.debug.clear();

    this.debug.lineStyle(1, 0x00ff00);

   
 

}

}

var config = {

type: Phaser.AUTO,

width: 1300,

height: 1000,

physics: {

    default: 'arcade',

    arcade: {

        gravity: { y: 0 },

        debug: false

    }

},

scene: Example,

};

var game = new Phaser.Game(config);

Maybe there’s a way to use the mesh vertices but I really don’t know.

Maybe fit some Geom objects by eye and then add static body zones for collisions.

I’m no expert, but I think getting smooth collisions with those barricades will be hard using arcade physics (circles and rectangles only, no ellipses or polygons from my understanding). You may want to use matter.js instead. See the tutorial below for some helpful starting info.

Full disclosure, I haven’t followed along with this specific tutorial, but I’ve followed other ones he has done and I have read through this one a few times when deciding how I wanted to handle collision in my game (went with arcade because it fit my needs better). Note: some things are in a slightly older version of Phaser 3, but perhaps this will still help.

I will try thanks.

Ok I will look on it, thanks