Jump to content

Recommended Posts

I'm trying to sove some doorse problem (actually like every door in the game) with code like this:

But i don't really get it. I need the exact coordinates of the bad spot (that is inside the wall, for example) to change it with my own coordinates.

I have tryed to calculate them but this is obviously not the "Exact" coordinates of the spot that bot is going to.

What is the easy way to do that? Am i have to just try all mesh spots, that are located close enough to the wall, one by one?

Thank you in advance for your answers.

The problem seems to be that once the bot is within a certain distance of the current waypoint it's navigating towards (for example once inside 2 meters) it moves on to the next waypoint. The main reason for this is that the closer it gets to the point it is running towards, the more erratic it looks, trying to get "exactly" to the waypoint. The result of this, especially if the path is coming from the left or right of the doorway (not directly straight-in from the front), is that once it gets close to the doorway, it turns towards the next waypoint (inside the building) and runs into the doorframe or wall next to the doorway.

The best way to make the bot navigate better through doorways is to somehow add a waypoint that is a few meters directly in front of the doorway, and navigate to that point before turning towards the door.

In the attached image, figure 1 shows the current path behavior. When the path approaches the waypoint in the doorway, once it gets within X meters of the waypoint (the blue circle shows this range), it turns towards the next waypoint and tries to follow the orange dashed line.

Figure 2 shows what happens if you add a waypoint directly in front of the doorway. 

Blank Diagram - Page 1.png

You are right, of course. The question is how to find the coordinates of the "bad" spot. You can't just add a spot whenewer you want for the pathfinder, so you have to use the code Droidz posted. And for that code, i belive, i need an exact coordinates of the next pathfinder spot, that forces the bot facehit the wall.

What I was trying to illustrate is that the "bad" spot is not inside the wall. It is the point in the doorway. It "becomes" a bad spot when the pather decides it's "close enough" to the doorway waypoint, and cuts the corner.

So you need to handle these on a case-by-case basis. If you see a point that is inside a tree, and your profile ends up repeatedly using this point, you'll need to add code like Droidz linked that when it sees this point on the nav path, it replaces it with a better point that is outside the tree. I don't believe there is a way to know a point is inside an object, but if you know about specific troublesome waypoints, you can look for that waypoint and replace it every time you see it.

Hope that makes sense, it's kind of hard to explain.

// Continent (item1), DefaultPosition (item2), DefaultPositionSearchRange (item3), NewPosition (item4)
        var positionChange = new List<Tuple<ContinentId, Vector3, float, Vector3>>
        {
            new Tuple<ContinentId, Vector3, float, Vector3>(ContinentId.Kalimdor, new Vector3(1422.318, -4662.921, 35.46182), 0.5f, new Vector3(1422.063, -4665.421, 35.46295)),
            /// new Tuple<ContinentId...
        };

        wManager.Events.MovementEvents.OnMovementPulse += delegate(List<Vector3> points, CancelEventArgs cancelable)
        {
            var continent = (ContinentId) Usefuls.ContinentId;
            foreach (var p in points)
            {
                foreach (var pchange in positionChange)
                {
                    if (p != null &&
                        pchange.Item1 == continent &&
                        p.DistanceTo(pchange.Item2) <= pchange.Item3)
                    {
                        Logging.WriteDebug("Change path position of " + p + " to " + pchange.Item4);
                        p.X = pchange.Item4.X;
                        p.Y = pchange.Item4.Y;
                        p.Z = pchange.Item4.Z;
                        p.Type = pchange.Item4.Type;
                        p.Action = pchange.Item4.Action;
                    }

                }
            }
        };

If you look at Droidz' code, this code constantly scans the current nav path, and looks for any point that is within 0.5 meters of (1422.318, -4662.921, 35.46182) and replaces it with (1422.063, -4665.421, 35.46295)

Basically, you have to know where these points are beforehand, and manually add each one to positionChange.

On 18.10.2017 at 6:52 PM, jrouten said:

// Continent (item1), DefaultPosition (item2), DefaultPositionSearchRange (item3), NewPosition (item4)
        var positionChange = new List<Tuple<ContinentId, Vector3, float, Vector3>>
        {
            new Tuple<ContinentId, Vector3, float, Vector3>(ContinentId.Kalimdor, new Vector3(1422.318, -4662.921, 35.46182), 0.5f, new Vector3(1422.063, -4665.421, 35.46295)),
            /// new Tuple<ContinentId...
        };

        wManager.Events.MovementEvents.OnMovementPulse += delegate(List<Vector3> points, CancelEventArgs cancelable)
        {
            var continent = (ContinentId) Usefuls.ContinentId;
            foreach (var p in points)
            {
                foreach (var pchange in positionChange)
                {
                    if (p != null &&
                        pchange.Item1 == continent &&
                        p.DistanceTo(pchange.Item2) <= pchange.Item3)
                    {
                        Logging.WriteDebug("Change path position of " + p + " to " + pchange.Item4);
                        p.X = pchange.Item4.X;
                        p.Y = pchange.Item4.Y;
                        p.Z = pchange.Item4.Z;
                        p.Type = pchange.Item4.Type;
                        p.Action = pchange.Item4.Action;
                    }

                }
            }
        };

If you look at Droidz' code, this code constantly scans the current nav path, and looks for any point that is within 0.5 meters of (1422.318, -4662.921, 35.46182) and replaces it with (1422.063, -4665.421, 35.46295)

Basically, you have to know where these points are beforehand, and manually add each one to positionChange.

You have wrote 4 messages with totally obvious information that was in my first 2 posts. I do appreciate that you are willing to help, but that leeds the thread in totally other direction, not what i have asked. As i said, i do understand what the idea is, the question is how to track bad spots easily.

P.S. And no, it's not constantly scan the path. It just do it once, replacing one point by another till the end of session.

In a word, i was askin it there any way to get atleast a detailed log of pathfinder spots.
Like:
Moving to: "x1, y1, z1"
Moving to: "x2, y2, z2"
Moving to: "x3, y3, z3"
... and so on.
So when bot is stuck in the doorway i was able to see what spot he is moveing to and replace it with my own.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...