Page 1 of 2

IgePathComponent problem

PostPosted: Sat Feb 28, 2015 5:11 pm
by Killersan
Guys, I have a huge problem and I need another pair of eyes to look at my code.
I have to use from 1.5.5. pathfinding functionality and it is working, but my character is "jumping". What does it mean.
I'm moving my character by clicking the mouse.
After game loaded, my character is on (0,0,0) point, so it's not in the middle of the tile (this is not the problem, only for testing purpose.
Now I'm starting to click on random tile for example (1,1).
Character is jumping in the middle of tile (0,0) after that is starting to move smoothly to tile (1,1).

After every click on the map when path is generating character is jumping instantly in to the middle of the current tile (on which this character reside in the time of the mouse click)

I didn't have such problem with previous version of IGE (1.3.1) .

Below is the short movie presenting this issue.

I'll paste full code that You could check it in Your environment.
Code: Select all
var Client = IgeClass.extend({
   classId: 'Client',
   init: function () {

      // Load our textures
      var self = this;
      this.obj = [];

      // Create the HTML canvas

      // Start the engine
      ige.start(function (success) {
         // Check if the engine started successfully
         if (success) {
            // Create the scene
            self.mainScene = new IgeScene2d()
                self.objectScene1 = new IgeScene2d()

                self.objectScene = new IgeScene2d()

            self.uiScene = new IgeScene2d()
               .ignoreCamera(true) // We don't want the UI scene to be affected by the viewport's camera

            // Create the main viewport
            self.vp1 = new IgeViewport()

            // Create an isometric tile map
            self.tileMap1 = new IgeTileMap2d()
                    .mouseUp(function (event, mig, data) {
                    var cord = this.mouseToTile();
                    var ply =self.player,
                        startTile = ply._parent.pointToTile(ply._translate);
                        ply.path.set(startTile.x, startTile.y, 0,cord.x ,cord.y, 0,true)

            // Define a function that will be called when the
            // mouse cursor moves over one of our entities
            overFunc = function () {

            // Define a function that will be called when the
            // mouse cursor moves away from one of our entities
            outFunc = function () {
                self.pathFinder = (new IgePathFinder).neighbourLimit(100);

                // Create the 3d container that the player
            // entity will be mounted to
            self.player = new Character()
            //   .addComponent(PlayerComponent)

                    .tileChecker(function (tileData, tileX, tileY, node, prevNodeX, prevNodeY, dynamic) {
                        // If the map tile data is set to 1, don't allow a path along it
                        if (typeof tileData === 'string'){return tileData === this._id;}
                        return tileData !== 1;
                    .allowSquare(true) // Allow north, south, east and west movement
                    .allowDiagonal(true) // Allow north-east, north-west, south-east, south-west movement
                    .drawPath(true) // Enable debug drawing the paths
                    .drawPathGlow(true) // Enable path glowing (eye candy)

            // Create a UI entity so we can test if clicking the entity will stop
            // event propagation down to moving the player. If it's working correctly
            // the player won't move when the entity is clicked.
            self.button1 = new IgeUiEntity()
               .backgroundPosition(0, 0)
               .mouseOver(function () {this.backgroundColor('#49ceff'); ige.input.stopPropagation(); })
               .mouseOut(function () {this.backgroundColor('#474747'); ige.input.stopPropagation(); })
               .mouseMove(function () { ige.input.stopPropagation(); })
               .mouseUp(function () { console.log('Clicked ' +; ige.input.stopPropagation(); })

            // Set the camera to track the character with some
            // tracking smoothing turned on (100)
  , 100);

if (typeof(module) !== 'undefined' && typeof(module.exports) !== 'undefined') { module.exports = Client; }

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 1:21 pm
by robaldred
Heya yeh this has been reported before by myself.

Basically this is a bug/side effect of the way the path timing works, this was introduced by the pathing rewrite last year.

I do not have a complete fix however, I created a workaround which I have used successfully implemented. Here's my solution...

Essentially, if the player is currently pathing it will queue up the next target tile. When the player walks over the next tile of it's current path the target tile is then changed to the latest that was clicked.

Here's some code:

Code: Select all
//Add a handler to your entites mouseUp event.
entity.mouseUp(function(event,control,data) {

Code: Select all
//Implement the handler on your player entity or something
   _mouseEvent: function(event, control, data) {
      //get the tile co-ordinates that the mouse is over.
      endTile = this._parent.mouseToTile();
      try {
      } catch (error) {
         //catch any instances where the next call fails.

Code: Select all
//implement the method that handles whether to path now or queue up
_newPathNext: function(tile) {
   var that = this;
   if(this.path._started && !this.path._finished) {
      // if pathing has started and it's still running, we need to queue up the next target
      // until we step on the next point to stop the teleporting.

      var newcb = function() {,tile);

      if(this.path.getToPoint() == this.path.getEndPoint()) {
         // we're on the last point so wait for pathComplete
         this.path.on('pathComplete', newcb, this, true);
      } else {
         // otherwise wait for the next pointComplete
         this.path.on('pointComplete', newcb, this, true)
   } else {
      // we're not pathing so do it now.

Code: Select all
_newPath: function(endTile) {
   if(!this._parent) {
   //now actually do the pathing to the new destination
   //make sure we clear the current path to reset all the internal path timers.

Hope that makes sense, it's quite a bit of code but I does work and is a reliable workaround I'm using in a live production game.

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 5:22 pm
by Killersan
Thanks Rob, this is very important for me to moved into 1.5.5. and as You know this new pathfinding released in 1.5.5. has some serious issues, which makes it unusable :( but it's good that You are here :)
I'll check Your workaround.
The only problem I've experienced is the "teleportation" of entity to the first tile of the path, which You mentioned in Your post, which I read while ago. I didn't notice that problem in Your movie, but now I can see that You wrote about it (I assumed that first movie shows the problem but it's private so I can't watch it).

I've searched the PathComponent for some kind of translation of entity on the first tile of the path, but I didn't find it, I'll try to implement Your solution now. It's good to hear that still You were handle to make such workaround and make it work it in Your production game.
We would like to start alpha tests by the end of the year. With my team we have a huge ambitions to build some serious game(s) in this engine, gather more ppl in IGE community which should help Irrelon to solve some critical bugs and maybe even develop new features. We need about month to make a documentation, use cases and schemas and after that we are starting programing part, still right now we have all hands on deck :) so I really appreciate for Your help Rob.

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 6:20 pm
by robaldred
I fixed my video. I think it illustrates what you're seeing too.
I'll investigate this if I find some time. I think it might need quite a bit of time to get to the bottom of it.
Maybe Rob from Irrelon can take a look?

Killersan, feel free to try and find the root of the issue within the IgePathComponent and patch the engine if you find a proper solution.

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 6:29 pm
by Killersan
Yes, the movie shows the same problem as we have. I'm counting on Rob from Irrelon too. His input in this engine is priceless.

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 9:38 pm
by robaldred
Ok I've fixed it
Pull request is awaiting confirmation

Re: IgePathComponent problem

PostPosted: Mon Mar 02, 2015 11:05 pm
by Killersan
Yes, I know that. We are very thankful for Your input RobAldred. I saw Your github pull request and I already implement it - working like a charm :)

Re: IgePathComponent problem

PostPosted: Sat Mar 28, 2015 5:28 pm
by Killersan
During our programming we faced into another problem with IgePathComponent. RobAldred's fix working but not on all aspects. After we turned on dynamic pathfinding, entities became to start teleporting if the path has been changed during the movement.

For now we don't have solution for it.

Re: IgePathComponent problem

PostPosted: Sat Mar 28, 2015 7:20 pm
by robaldred
Hey. Can you share the source for that demo?
Does this only happen after my patch?

I'll take another look, sorry about that.

Re: IgePathComponent problem

PostPosted: Mon Mar 30, 2015 12:17 am
by Killersan
Yes it's only after Your fix but without it we know what happens, entities will teleport anyway but in different situation.
Below is the source of the example.

I have to say that I'm a little surprised that such major problem which reflects on whole engine is not even touched by anyone from Irrelon.
This is strange because they've put tons of work into this engine, which is a great work and in my opinion shouldn't die because of lack support from the owner/producer.