Pathfinding or not!

Hi there .
I checked this site, and wanted to know If he used pathfinding with tiles or just collisions detection methods -
[url=“http://www.qlod.com/experimentos/”]
http://www.qlod.com/experimentos/
“2002” and then “steering”

I tried some code for make an object following a path
with HitTest but its not really working ,
Could somebody help me with the HitTest optimisition so i don’t have to write it everytime … and the turning part is not too smooth !!! any idea ?

edit

Well I found the way to optimise the hitest part My code is now looking like this … But I still can’t figure out how to make turn the mc so its not doing this robot like effect : i tried to add a factor to the rotation but it don’t work …
Need Help !!!

pathdirection.html


  <actionscript>
  onClipEvent (load){
   	speed = 5	
   	i=1 // init the Current Check 
   	nChecks = 8 // The numbers of checks
   	x_dest = _root["c"+i]._x; // x position of the Current Check 
   	y_dest = _root["c"+i]._y; // y position of the Current Check 
   	
   function nextCheck (){
   	if (this.hitTest(_root["c"+i])){ // hitTest between this mc and the check 
   	if (i<nchecks ){i++}else{i="1}" next="" check="" or="" -="">
   		x_dest = _root["c"+i]._x; // reinitialise the check to the 1st one
   		y_dest = _root["c"+i]._y;	
   		}
   	}
   }
   onClipEvent (enterFrame){
   nextCheck ();
   
   x = _x-x_dest; // x distance between this mc and the next check
   y = _y-y_dest; // y distance between this mc and the next check
   _rotation = - (Math.atan2(x,y))/(Math.PI/180); // rotate this mc 
   _y -= speed*Math.cos(_rotation*(Math.PI/180)); // --------------
   _x += speed*Math.sin(_rotation*(Math.PI/180)); // --------------
   	
   }
   
     

</nchecks></actionscript>

lastchildz,

I want to study tour code but, please, post the fla of this example. I guess it’ll solve my problem too.

see ya

Hi Akirasan,
Here is the file ,
this code is just a study and need a lot of improvment , Let me know if you can get something with it :wink:

Later .
Lastchildz

ooooooh man, I’ve tried so many times to make an object try to get another object like that, so that it has a turn threshold type thing, so that it moves smoothly.

Hellow,

Lastchildz, I’ve doing some code while waiting for your source and I got this one:

following.html
following.fla

In this test I’m trying to make a car to steering to a specific point. It’s not very good but it’s a begining! The code is very redundant, I’m sure that a lot of improvemet can be done.

Applying this test to your code, I got this:

pathdirection2.html
pathdirection2.fla

As you can see, the car’s moviment is much better now! But still not very good, I guess that despite using HitTest, compare (x,y) position is a better choice…

Anyway, this is a good start!

see ya

Hi Akirasan .

Cool you’re code look to work pretty good .
I can’t code right now as I am preparing my wedding . . .
And got a lot of things to take care of .

I Let you know as soon as I am more available .
LAter .
Lastchildz .