Jump to content
Search Community

dabuttmonkee

Members
  • Posts

    3
  • Joined

  • Last visited

dabuttmonkee's Achievements

0

Reputation

  1. FIXED! In case anyone cares, the problem was I didn't take in to account the difference in p1.x>p2.x and p1.x Thanks for the great product man. It's totally amazing.
  2. After a lot of debugging it seems to be a problem with my code, NOT the bezier algorithm. My bad!
  3. Hey all, I am coding an enemy walking through a path and to make realistic motion I decided to use the Bezier plugin. Anyway, my code works perfectly for almost every situation except when turning up and to the right. It does this weird loopdeloop. Here is my code: private function gotoNextTile(ptTile:Point):void { if (_path[_currentTile+1]) { //point that I'm at var p1:Point = ptTile; //point that I'm going to var p2:Point = _path[_currentTile + 1]; //distance between the points and the time it //should take to get there var dist:Number; var t:Number; //the tweening properties var twX:Number; var twY:Number; var bezX:Number; var bezY:Number; //determine if they're parallel along the x axis if ((p1.y == p2.y) && (p1.x != p2.x) ) { trace(1); twX = p2.x * TILE_WIDTH; twY = (p2.y + .5) * TILE_WIDTH; //tween through the middle of the current tile bezX = (p1.x+.5 ) * TILE_WIDTH; bezY = (p1.y+.5 ) * TILE_WIDTH; } else if((p1.x == p2.x) && (p2.y != p1.y)) //determine if they're parallel along the y axis { trace(2); twY = p2.y * TILE_WIDTH; twX = (p1.x + .5) * TILE_WIDTH; //tween through the middle of the current tile bezX = (p1.x + .5) * TILE_WIDTH; bezY = (p1.y + .5) * TILE_WIDTH; } else if (p1.x != p2.x && p1.y != p2.y ) { trace(3); twX = (p2.x + .5) * TILE_WIDTH; twY = (p2.y + .5) * TILE_WIDTH; //tween through the middle of the current tile bezX = (p1.x) * TILE_WIDTH; bezY = (p1.y) * TILE_WIDTH; } dist = Math.sqrt(((p2.x + .5) * TILE_WIDTH - (p1.x + .5) * TILE_WIDTH) * ((p2.x + .5) * TILE_WIDTH - (p1.x + .5) * TILE_WIDTH) + ((p2.y + .5) * TILE_WIDTH - (p1.y + .5) * TILE_WIDTH) * ((p2.y + .5) * TILE_WIDTH - (p1.y + .5) * TILE_WIDTH)); t = dist / _velocity; trace(" Going to: " + p1 +"\n "+ twX + ", " + twY + "\n and Beziering Through: " + p2 +"\n "+ bezX + ", " +bezY +"\n In " + t + "s"); _currentTile++; TweenMax.to(this, t, { bezier:[ { x:bezX, y:bezY }, {x:twX,y:twY } ], orientToBezier:true, ease:Linear.easeNone, onComplete:gotoNextTile, onCompleteParams:[p2] } ); } } Any help would be awesome! thanks people!
×
×
  • Create New...