IgePathComponent problem

Post your help queries and engine programming questions here

IgePathComponent problem

Postby Killersan » Sat Feb 28, 2015 5:11 pm

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.
http://youtu.be/TZtzyQAi8VU

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

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

      // Create the HTML canvas
      ige.createFrontBuffer(true);

      // Start the engine
      ige.start(function (success) {
         // Check if the engine started successfully
         if (success) {
            // Create the scene
            self.mainScene = new IgeScene2d()
               .id('mainScene')
               .drawBounds(false)
               .drawBoundsData(false);
                self.objectScene1 = new IgeScene2d()
                    .id('objectScene1')
                    .depth(0)
                    .drawBounds(false)
                    .drawBoundsData(false)
                    .mount(self.mainScene);

                self.objectScene = new IgeScene2d()
                    .id('objectScene')
                    .depth(0)
                    .drawBounds(false)
                    .drawBoundsData(false)
                    .mount(self.objectScene1);


            self.uiScene = new IgeScene2d()
               .id('uiScene')
               .depth(1)
               .drawBounds(false)
               .drawBoundsData(false)
               .ignoreCamera(true) // We don't want the UI scene to be affected by the viewport's camera
               .mount(self.mainScene);

            // Create the main viewport
            self.vp1 = new IgeViewport()
               .id('vp1')
               .autoSize(true)
               .scene(self.mainScene)
               .drawMouse(true)
               .drawBounds(true)
               .drawBoundsData(true)
               .mount(ige);

            // Create an isometric tile map
            self.tileMap1 = new IgeTileMap2d()
               .id('tileMap1')
               .isometricMounts(true)
               .tileWidth(40)
               .tileHeight(40)
               .drawGrid(1)
                    .gridSize(5,10)
                    .drawMouse(true)
               .drawBounds(false)
               .drawBoundsData(false)
               .mount(self.objectScene)
                    .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)
                            .speed(1)
                            .start();
                    });

            // Define a function that will be called when the
            // mouse cursor moves over one of our entities
            overFunc = function () {
               this.highlight(true);
               this.drawBounds(true);
               this.drawBoundsData(true);
            };

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

                // Create the 3d container that the player
            // entity will be mounted to
            self.player = new Character()
               .id('player')
            //   .addComponent(PlayerComponent)
                    .addComponent(IgePathComponent)
                    .isometric(true)
               .mouseOver(overFunc)
               .mouseOut(outFunc)
               .drawBounds(false)
               .drawBoundsData(false)
               .mount(self.tileMap1);


                self.player.path
                    .finder(self.pathFinder)
                    .tileMap(self.tileMap1)
                    .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;
                    })
                    .lookAheadSteps(3)
                    .dynamic(true)
                    .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)
                    .drawPathText(true);

            // 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()
               .id('testUiEntity')
               .depth(1)
               .backgroundColor('#474747')
               .top(0)
               .left(0)
               .width('100%')
               .height(30)
               .borderTopColor('#666666')
               .borderTopWidth(1)
               .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 ' + this.id()); ige.input.stopPropagation(); })
               .mount(self.uiScene);

            // Set the camera to track the character with some
            // tracking smoothing turned on (100)
            self.vp1.camera.trackTranslate(self.player, 100);
         }
      });
   }
});

if (typeof(module) !== 'undefined' && typeof(module.exports) !== 'undefined') { module.exports = Client; }
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: IgePathComponent problem

Postby robaldred » Mon Mar 02, 2015 1:21 pm

Heya yeh this has been reported before by myself.
viewtopic.php?f=5&t=169&p=729

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) {
   this._handleMouseUp(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 {
         this._newPathNext(endTile);
      } 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() {
         that.newPath.call(that,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.
      this._newPath(tile)
   }
})



Code: Select all
_newPath: function(endTile) {
   if(!this._parent) {
      return;
   }
   //now actually do the pathing to the new destination
   //make sure we clear the current path to reset all the internal path timers.
   this.path.clear();
   this.path.add(tile.x,tile.y,0,true);
   this.path.speed(this._speed);
   this.path.start();
});


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.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: IgePathComponent problem

Postby Killersan » Mon Mar 02, 2015 5:22 pm

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.
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: IgePathComponent problem

Postby robaldred » Mon Mar 02, 2015 6:20 pm

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.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: IgePathComponent problem

Postby Killersan » Mon Mar 02, 2015 6:29 pm

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.
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: IgePathComponent problem

Postby robaldred » Mon Mar 02, 2015 9:38 pm

Ok I've fixed it
Pull request is awaiting confirmation
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: IgePathComponent problem

Postby Killersan » Mon Mar 02, 2015 11:05 pm

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 :)
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: IgePathComponent problem

Postby Killersan » Sat Mar 28, 2015 5:28 pm

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.
http://youtu.be/6wp8LIfxUyg
http://youtu.be/WyPSoZOFmPA

For now we don't have solution for it.
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Re: IgePathComponent problem

Postby robaldred » Sat Mar 28, 2015 7:20 pm

Hey. Can you share the source for that demo?
Does this only happen after my patch?

I'll take another look, sorry about that.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: IgePathComponent problem

Postby Killersan » Mon Mar 30, 2015 12:17 am

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.
http://www.screencast.com/t/Zib9xQPm

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.
User avatar
Killersan
 
Posts: 24
Joined: Sat Jun 21, 2014 1:45 pm

Next

Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron