Jump to content

Help Understanding the follower object...


Malikaijack
 Share

Recommended Posts

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

balambstudent_m.png

city.json

city.png

edwardvonmuir.png

farisscherwiz.png

fish.png

goldcoin.png

greenbook.png

healingsalve.png

honeybee3.png

Horseshoe.png

jecht.png

leblanc.png

magecity.png

milk.png

net.png

notebook.png

odin.png

player.png

redxiii.png

scarf.png

seed_m.png

shiva.png

silvercoin.png

stone.png

stragomagus.png

sword.png

terrabranford.png

trabiastudent_m.png

yangfangleiden.png

Edited by Malikaijack
added files, explained what I have tried for clarity
Link to comment
Share on other sites

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

  • 1 year later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...