Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (TedMar), 1,420 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using the same path to many actors #10706
10/17/02 09:41
10/17/02 09:41

A
Anonymous OP
Unregistered
Anonymous OP
Unregistered
A



I have a path object and would like to use it to give a way for many actors.

Any actor is placed in a diferent position along this path but allways near or on the line. It means that the actor placed near by the first waypoint will work normaly with the acctual function. But the next actor can be near to the nth. waypoint.

How can I do to make the others start following the nth. waypoint?

Thanks

Re: Using the same path to many actors #10707
10/24/02 04:59
10/24/02 04:59
Joined: Jun 2002
Posts: 248
NZ
mudhole Offline
Member
mudhole  Offline
Member

Joined: Jun 2002
Posts: 248
NZ
You could use the normal scan_path to find the path that the actor is nearest to, then cycle through all the points on the path to check which one is closest. Just start the actor from this point.

eg.

code:
var numPoints;
var nearestPoint;
var minDist;
...
// find the path - you could also use numPoints = ent_path("yourPathName");
temp.pan = 360; // scan the full sphere
temp.tilt = 180;
temp.z = 1000; // max distance the entity can be from the first waypoint
numPoints = scan_path(my.x,temp);


// find the closest point on the path
nearestPoint = 0;
ent_waypoint(vecTo,nearestPoint);
minDist = vec_dist(my.x,vecTo);
temp = 1;
while(temp < numPoints)
{
// retrieve the next point
ent_waypoint(vecTo,temp);

// compare to the previous nearest point
if(vec_dist(my.x,vecTo) < minDist)
{
// found a new nearest point
nearestPoint = temp;
minDist = vec_dist(my.x,vecTo);
}

temp += 1;
}

// nearestPoint now holds the index of the waypoint closest to the actor




Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1