I am developing a game and implemented pathfinding algorithm. My pathfinding returns me a array of nodes which character has to move through to reach the destination. Basically I need to tween node by node so I use TimelineLite and add all the tween to the sequence. It works.
HOWEVER,
There are delays when tweenning between nodes (character moves, then stop, then moves again…) which I couldn’t figure out the reason. How can I solve it?
Here is the code:
public function walk(startNode:Node,destinationNode:Node):void{
//retrieve the path of the character
var path:Array = Pathfinder.findPath(startNode,destinationNode,GenericMap.findConnectedNodes);
currentPath=path;
if(path!=null){
var pastX:Number;
var pastY:Number;
for(var index:int=0;index<path.length;index++)
{
var currentNode:Node = path[index] as Node;
testMoveThroughNodes(currentNode.x,currentNode.y);
}
}
}
private var speed:Number = 0.7;
private var timeline:TimelineLite = new TimelineLite();
/** tween the sprite through nodes of path*/
private function testMoveThroughNodes(targetX:Number,targetY:Number):void{
timeline.append(new TweenLite(monster,speed,{x:targetX,y:targetY}));
}
I able to tween through each node sequencing TweenLite, however it moves and stop and moves, look totally unnatural.
Yeah, tough to say without seeing any code, but I wonder if it’s just an easing issue that makes it LOOK like things are stopping briefly even though they’re not. Remember, the default ease is Quad.easeOut, so movement slows towards the end of each tween (for a more natural “feel”). You can use Linear.easeNone if you want linear movement.