Jump to content

GetDistance


cassius
 Share

Recommended Posts

Yea. Its just that one of my enemy characters stops following main character sometimes but not always.

I wondered if hills got in the way.

I've had the same problem with Follow(), I can't remember what I had done to fix it... or if I fixed it at all. Two things stick out in my mind, 1) What does Follow() do when the player is suddenly unreachable? Like if they jumped onto a platform that the navmesh doesn't connect to. 2) Is your script continuously calling Follow()?

 

It'd be nice if the Navigation API had a function like IsFollowing() so that you could detect when the path failed for some reason.

Link to comment
Share on other sites

If you want distance to be checked with the hills, you can store the waypoints and calculate the distance between each waypoint.

 

When looking at my old code, I think it's being done something like this:

std::vector<Vec3> waypoints;
//Vec3 targetPos = Vec3(60);

world->navmesh->FindPath(model->GetPosition(true), targetPos, waypoints);
float distance = 0;
for (uint16_t i = 0; i < waypoints.size() - 1; ++i) // you can also use unsigned int instead
{
distance += waypoints[i].DistanceToPoint( waypoints[i + 1] );
}
printf("Total distance is: %0.2f\n", distance);

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...