Hi I am currently working on a very simple isometric3d game with a hero to move to mouse click position, using path-finding. I am trying to code everything myself step by step,as a beginner , i am well aware of asolib3d but I don't want to use it...I have read tutorials and few books I completely done with my isometric3d map. i create my path finding A-star class which is working perfectly with 2d grid tiles, but when i try to use it with isometric3d grid world it doesn't work properly and this is where i am asking your help.it's not the best code but i am trying and sorry for my english.. ps: Patfhinding is very simple i use the wiki algorithm and it return an array of int.
Code:
package{
import com.sayConcept.isometric.IsoUtils; import com.sayConcept.isometric.GraphicTile; import com.sayConcept.isometric.IsoWorld; import com.sayConcept.isometric.Point3D; import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.geom.Point; import flash.events.MouseEvent; import flash.filters.GradientBevelFilter; import flash.text.TextField; import fl.motion.MotionEvent; import flash.events.Event; [SWF(backgroundColor=0xffffff)] publicclassTheGameextendsSprite{ privatevar world:IsoWorld; [Embed(source="src/images/grass.png")] privatevar grass:Class; privatevar player:GraphicTile; [Embed(source="src/images/grass1.png")] privatevar grass1:Class; privatevar pos:Point3D; privatevar index:int; privatevar _walk:Array; privatevar startx:int=0; privatevar starty:int=0; privatevarNewstartx:int; privatevarNewstarty:int; publicfunctionTheGame(){ stage.align =StageAlign.TOP_LEFT; stage.scaleMode =StageScaleMode.NO_SCALE; world=newIsoWorld(); world.x=stage.stageWidth/2; world.y=100; addChild(world); for(var i:int=0; i<20; i++) { for(var j:int=0; j<20; j++) { //creating my iso world..adding object grass var tile:GraphicTile=newGraphicTile(20,grass,20,10); tile.position=newPoint3D(i*20,0,j*20); world.addChildToFloor(tile); } } // stage.addEventListener(MouseEvent.CLICK,addNewTile); if(Newstartx==0&&Newstarty==0) { addPlayer(startx,starty); } else { addPlayer(Newstartx,Newstarty); } stage.addEventListener(MouseEvent.CLICK,onEnterFrame1); } privatefunction addPlayer(startx:Number, starty:Number):void { player=newGraphicTile(20,grass1,20,20); var pos:Point3D=IsoUtils.screenToIso(newPoint(startx, starty)); pos.x=Math.round(pos.x/20)*20; pos.y=Math.round(pos.y/20)*20; pos.z=Math.round(pos.z/20)*20; player.position=pos; world.addChildToWorld(player); } privatefunction onEnterFrame1(e:Event):void { trace("mouse"+world.mouseX+","+world.mouseY); pos =IsoUtils.screenToIso(newPoint(world.mouseX,world.mouseY)); var targetX:Number=Math.round(pos.x/20)*20; var targetY:Number=Math.round(pos.y/20)*20; var targetZ:Number=Math.round(pos.z/20)*20; var path1:Pathfinding=newPathfinding(); _walk=newArray(); //check if =to zero if(Newstartx==0&&Newstarty==0||Newstartx==undefined&&Newstarty==undefined) { startx=Newstartx; starty=Newstarty; } else { //new position for hero => new reach goal startx=Newstartx; starty=Newstarty; } //call to pathfinding if( path1.Path(startx/20, starty/20,targetX/30,targetZ/20)) { addEventListener(Event.ENTER_FRAME,loop,false,0,true); //_walk=path1.Path(player.position.x/20, player.position.z/20,targetX/40,targetZ/40); _walk=path1.Path(startx/20, starty/20,targetX/20,targetZ/20); Newstartx=targetX; Newstarty= targetZ; } } ////looop privatefunction loop(e:Event):void { var pathX:Number= _walk[index].x *20+20/2; var pathY:Number= _walk[index].y *20+20/2; var dx:Number= pathX - player.x; var dy:Number= pathY - player.y; var temp:Number=Math.sqrt(dx * dx + dy * dy); if(temp <1) { index++; if(index >= _walk.length) { index=0; startx=_walk[index].x *20+20/2; starty=_walk[index].y *20+20/2; removeEventListener(Event.ENTER_FRAME, loop); } } else { player.x += dx *.3; player.y += dy *.3; ////show path on the nodes grid graphics.beginFill(0x660000); graphics.drawCircle(player.x ,player.y *20,4); graphics.endFill(); } } }
}
here is the swf
https://www.yousendit.com/download/M...ZEs3bURFdzhUQw


Let me explain, my character movement is not correct. If hero position=0,0 and I click 0,10 on my iso grid instead of moving down he will move on the right side. If I am in the middle and I click on the left he will move right. and like few steps for where it supposes to stop... my pathfinding is ok in 2d but isometric the movement is weird...Can anyone explain to me how I could fix this, or point me to any examples or tutorials. I just want my hero to move to the path correctly...thank you.

nb targetX targetY TargetZ are the coordinates point on the isometric3d base on the formula y is always equal to 0 this is why i put targetX and targetZ so NewStartY is actually newStartZ. _walk is an array that contains the path that has been found. the trace give me some quite high number and this is where i am lost on the movement i don't really get that part. i am going to post the code so you can see if you allow me of course it's a little bit difficult to explain myself the right way