# Pathfinding or not!

**URL:** https://forum.kirupa.com/t/pathfinding-or-not/58871
**Category:** Uncategorized
**Created:** [July 26, 2004, 7:01pm UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871 "2004-07-26T19:01:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lastchildz](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@lastchildz](https://forum.kirupa.com/u/lastchildz)
#### Post date: [July 26, 2004, 7:01pm UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/1 "2004-07-26T19:01:28Z")

</div>

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/)”]  
[http://www.qlod.com/experimentos/](http://www.qlod.com/experimentos/)  
“2002” and then “steering”

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 27, 2004, 11:47pm UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/2 "2004-07-27T23:47:58Z")

</div>

## 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](http://www.12-oclock.com/pathdirection.html)

```auto

  <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\>

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 7, 2004, 6:57pm UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/3 "2004-08-07T18:57:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 9, 2004, 3:53am UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/4 "2004-08-09T03:53:44Z")

</div>

> [@Akirasan](#):
>
> 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 😉

Later .  
Lastchildz

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 9, 2004, 5:17am UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/5 "2004-08-09T05:17:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 11, 2004, 2:13am UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/6 "2004-08-11T02:13:21Z")

</div>

Hellow,

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

[following.html](http://www.mrshp.hpg.ig.com.br/following.html)  
[following.fla](http://www.mrshp.hpg.ig.com.br/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](http://www.mrshp.hpg.ig.com.br/pathdirection2.html)  
[pathdirection2.fla](http://www.mrshp.hpg.ig.com.br/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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 12, 2004, 8:06pm UTC](https://forum.kirupa.com/t/pathfinding-or-not/58871/7 "2004-08-12T20:06:55Z")

</div>

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 .
