Malikaijack Posted June 6, 2018 Share Posted June 6, 2018 (edited) So I am working on my just general knowledge of how phaser works, I have only done two tutorials. But I think I have a decent grasp on it so far. But I am running into a little problem, I am trying to use the Follower object, so that I don't have to create the vec2 and attach it, but I don't seem to understand the documentation or what it means by "If this Game Object is enabled for physics then this property will contain a reference to a Physics Body." I have scoured the docs for hours. I see how to 'enable' in arcade physics but I cannot find any reference to how with impact physics. I am able to create a body object, and assign it to the game object, as well as assign the the game object to the body, but they do not move in tandem. in fact the body does not move at all. P.S. This is not the only bug, when converting from matter.js to impact.js physics my logic on pausing player movement when the dialog modal broke. but one problem at a time.. P.P.S I know its not the best code //SHIVA path3 = new Phaser.Curves.Path(550, 450); path3.lineTo(450, 450); path3.lineTo(450, 505); path3.lineTo(550, 505); path3.lineTo(550, 450); path3.lineTo(450, 450); shiva = this.add.follower(path3, 550, 450, 'shiva'); //Phaser.GameObjects.BuildGameObject(this, Phaser.GameObjects.PathFollower) //this.game.physics.enable(shiva, impact); shivaBody = this.impact.add.body(550, 450, 16, 12); //TRYING DIFFERENT WAS TO SET BODY //shivaBody.setOffset(550, 450, 16, 12); shiva.body = shivaBody; shivaBody.setGameObject(shiva); shiva.name = "shiva"; shiva.setRotation(); shiva.depth = 30; //ALT WAY TO GET NAME //shiva.name = "shiva"; shiva.setData(npc, true); shiva.setData("name", "shiva"); npcBodies[2] = shivaBody; npcs.add(shiva); shiva.startFollow({ ease: 'Linear', duration:6000, yoyo:true, repeat: -1, _delay: 200, delay: 100 }); P.P.P.S I also tried this.physics.world.enable(shiva); this.impact.world.enable(shiva); dialog_plugin.js game.js index.html city.json Edited June 6, 2018 by Malikaijack added files, explained what I have tried for clarity Link to comment Share on other sites More sharing options...
Malikaijack Posted June 7, 2018 Author Share Posted June 7, 2018 I have also Tried converting to arcade, and I can't assign collision with the NPCs or the collision layer. let map = this.make.tilemap({key: 'map'}); let tileset = map.addTilesetImage('magecity'); let DynamicLayer = new Phaser.Tilemaps.StaticTilemapLayer(this, map, 0, tileset, 0, 0); player = this.physics.add.sprite(this.sys.game.config.width / 2, 556, 'player'); player.name = "player"; playerGroup = this.add.group(); playerGroup.add(player); this.physics.world.enable(player); npcs = this.add.group(); path1 = new Phaser.Curves.Path(20, 40); path1.lineTo(100, 40); balambStudent = this.add.follower(path1, 20, 40, 'balambStu'); this.physics.world.enable(balambStudent); npcs.add(balambStudent); this.physics.world.collide(player, npcs); this.physics.world.collideGroupVsTilemapLayer(playerGroup, DynamicLayer, null, null, this, true); Link to comment Share on other sites More sharing options...
Malikaijack Posted June 7, 2018 Author Share Posted June 7, 2018 this works in arcade. this.physics.add.collider(player, npcs, collide, null, this); Link to comment Share on other sites More sharing options...
Malikaijack Posted June 7, 2018 Author Share Posted June 7, 2018 this works for the collision layer for arcade. collisionLayer.setCollisionByExclusion([-1]); Link to comment Share on other sites More sharing options...
MagNus_Chrom Posted October 2, 2019 Share Posted October 2, 2019 Thanks for posting the answers you discover! I see a lot of that here, people answering their own questions. Thanks, you have helped me a lot! Link to comment Share on other sites More sharing options...
Recommended Posts