A script to get the Vector3 position of the current next node

Hello Aron

I just started to use A* Pathfinding Project Pro, and I must say, it is really a tremendous asset!
I followed the tutorials, looked into all the modifiers, it really has a lot of features!

However, here is my problem, I would need a script to be able to get the next node’s position (once modifiers have been applied if possible). I am modeler, I don’t know how to code, but thanks to playmaker I have been able to create some decent games by myself. If I had only this simple script, i would be able, using the playmaker’s “get property” action, to fully convert my AI’s from Unity’s navmesh to your path-finding method (I am currently using the recastgraph, amazingly fast by the way).

I saw a thread from mirek_mazur where you seemed to basically answer the question, but I don’t know how to make it sadly I don’t know how to make it work, and my modelings are already taking me an awful lot of time…

I know that people requesting code are a pain for coders like you, but this single script would permit me to completely combine all the features you provide with mine without troubling you anymore. Also if I can help you in an other way in exchange just ask!

Thank you for the help

Hi

When modifiers have been applied it often no longer makes sense to ask for the ‘next’ node as the path may be very different from the original path. What is it that you want to accomplish with this?

Wow that’s a quick response!

Well I use a lot of root-motion to move my characters, as well as some complex state machines.
With the unity navmesh I manly used the “next steering target” position to choose how I would make the AI move (speed rotation etc). But it’s not only that. For example when the next steering target was close, I would make it jump, or say a line. With the position of the next steering target, I could get a lot of informations by comparing it with the distance from AI, the angle, the environment around etc and then making it behave in a unexpected but still logical way.

When I use the funnel modifier on the recastgraph, the path line is pretty straight with some precise angles, and being able to know the position of the next angle would be a real great help to port my AI to your path-finding method without having to start all from scratch.

Ah, ok, so not the next node, but the next point in the path.

I am not sure what movement script you are using, but pretty much all movement scripts keep the list of all points in some variable named ‘vectorPath’ or a similar name, and keep the current index for the next point to move to so you can get that point using vectorPath[index]. The Seeker component will just calculate the path, but after that it does not really care about it, you would need some kind of movement script that actually stores the path. The get started tutorial has a very simple example script.

Well, I have followed get started tutorial, and it worked perfectly well, but not for my AI.
I already have the “kind of movement script” with my Playmaker FSM, the only thing I need to make it work is this Vector3. The movement is done by the animations themselves thanks to root motion.

So if I understood completely, it’s not possible as of yet to have the equivalent of the “next steering target” in A*? Even if it’s a somewhat heavy code? (I’m using root motion for characters in a fps, there won’t be tons of them on screen, and when they are far I can put them back on pathfinding driven movement for optimization).

Anyway thanks for the help and the quick responses! :slight_smile:

Hi

Since you are using Playmaker, do you actually calculate a path? And if so, how is that stored?

Well that’s my problem so far : I have my playmaker FSM, I have your script that calculate a path, but I can’t find a way to mae them communicate :pensive:

The only thing that my FSM needs from your pathfinding setup to do its job is this (in)famous next steering target. That’s why I was wondering if it was possible to write a short script that makes this steering target (a vector3) accessible.

For the destination I simply put an empty gameobject in your script, and I move it thanks to my FSM wherever I want.

It’s only the position where my AI should walk toward that I need to have it all ready

Hi

This might work:
Add a RichAI component, but set the speed to zero. Then you can get the target point from the RichAI.TargetPoint property.

It works perfectly! :smiley:

Alright, just a little recap for other playmaker users that might be looking for the same thing :
Setup your AI just like it is explained in the get started tutorial. Put the rich AI, the seeker, and any modifier you need on your AI.
Now create your FSM, and drag and drop the rich AI from your AI in a node. It will ask you to choose beetween “set property” and “get property”, choose the latter. Now on your action, go to the property section and select property>TargetPoint>x store it in a float, and do the same for y and z. Now create a “set vector3 XYZ” action, and combine the three previous floats to get the steering target’s vector3.

Thank you a lot Aron! You’ve been really helpfull, patient, and incredibly quick. Now I’ll be able to explore the full potential of your asset! (Oh and writing a review on the store right away) If you need anything on the modeling side, just let me know! :wink:

1 Like

Great that it works!
Good luck with your game!

Thanks! Keep up the good work!

Thank you for this post! I was trying to do the same thing. I noticed steeringTarget has been implemented.