playMaker

Author Topic: A* pathfinding (stable 0v841)  (Read 230351 times)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #180 on: August 06, 2013, 04:36:10 PM »

Thank you for your work on this. It is hugely helpful. I am having trouble with the follow action. If I duplicate the object doing the following, it appears to stutter. When one of the objects is deleted, all objects finish the path they had last.

Am I doing something wrong?

Allright, I don't know why this bug is happening, apparently playmaker fsms continue running until the end of a frame, even if the actual gameobject they are on is being destroyed. Anyways, I fixed it in the new release by adding an additional conditional check.

0v83 changelog:

 unify speed setting in MoveTo for all controllers (so you can change the controller without having to adjust the speed setting) [done]
- make IgnoreY also work on the Finish Distance [done]
- fix rvo controller speed issues [done]
- add rigidbodyVelocity movement mode(sets rigidbody velocity to direction)[done]
- calculate ETA action (one of the benefits a unified speed setting offers) [done]
- stuttering issue if you duplicate an actor that follows [unfixable] you need to use a pooling system.
- bug if you delete one of many actors that follow [fixed]


to upgrade from 0v82 0v83 just install the pro package on top of your current project, even if you're using the free version.
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #181 on: August 08, 2013, 05:10:49 AM »
hi,

I've just gotten into playmaker and especially your A* implementation. And it worked out of the box quite rapidly.. so kudos for that. 

But what I can't seem to get to work, is simply finding nodes and walkability.

Right now, I generate a level with point node objects,
I've rigged the A*star manager to greate a pointgraph based on these tagged node objects.. This works. 

After I generate, I perform a scan, to setup all the dynamically created nodes in the graph.  This also works great

now I use a moveto/follow/transform setup to get my unit to move along the graph to the mouse pointer.. This also works great..

Seeing as this is a strategy game I need 25 units to use the pointgraph..
Do keep this doable on mobile, i've decided to not have any avoidance or walkability changes when a group of units is moving,  but when they reach their destination, I would like to set a property of the node as occupied. And thus not have that node assigned as a target for other units. 

But whatever I try, I can never use get nearest node or any other node action, The output to the FSMnode gameobject var is always null.

am I forgetting a step, do I need to store the nodes somewhere? is the scangraph action not viable in the free version?  or can't you acces dynamically created nodes in the free version?

Would be great if anyone could point me in the right direction.  Seeing as the moveto is working great, I should be able to getnearest node and such.

thanks, and here's a video of what i got working so far.(only the ground unit is using a*)
I can work around it by creating a target manager, that passes only allowed target objects to the moveto, but would still like to use a little more of the a* if possible:)

cheers and kudos for the great addon again.

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #182 on: August 08, 2013, 07:52:36 AM »
Hey muppetpuppet, your game looks awesome! I checked the get nearestNode action on Point Graphs and it should work. Can you send me a screenshot of your action setup? I used this :
MousePick (save position as pos)
GetNearestNode (pos, save node)
GetNodeInfo(node, save walkability to walk)
BoolToString(walk to walkString)
GUI Label (walk String)

with all set to every frame it correctly returns whether the node under to mouse cursor is walkable or not.
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #183 on: August 08, 2013, 12:40:05 PM »
I'll send a screen when I get back to my pc.(probably tommorow sadly:(

but perhaps its because I use the target object instead of a position, will try also.

I've just made a little target manager, that assigns a unique end-node close to the target pos, per unit.  Which works quite well for now.

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #184 on: August 09, 2013, 06:23:31 AM »
here's a screen of a simple picker..  (the right state isn't active when in grabbed the shot, but I can verify that it had been activated a bunch of times during the runthrough, and it passes the same target point to the actual units for following.  Which works fine..
but as you can see the node output on the inspector is none.. (or is the output bugged, but perhaps it is set internally, seems unlikely but ok)

cheers

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #185 on: August 09, 2013, 06:43:44 AM »
Oh, yeah, that's playmaker for you :D The FsmVariables I introduced do not contain components but actual object variables. So they are not recognized by Playmaker (eg you notice that component object variables do not show the name of the component if they are assigned, but the name of the gameObject they exist on. My variables exist independently from any gameObject so they always show as null.)
To see whether it's assigned just use a get node/path/etc info action.
Hope this works now :D
Btw, next update will finally feature a smooth movement action. Not sure if you need it in your project but I saw it as overdue. :}
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #186 on: August 09, 2013, 07:43:43 AM »
Aaaah that explains, I should have just explored further down the chain so to speak.

Is there code to retreive from a node the original gameobject that was used as the original reference during the scan?

That way I can code other stuff around nodes not related to the a*, but won't have to perform a find closest or anything really slow for lots of node originals (i hope this makes sense btw.)

A smooth motion would be great, I've now created my own smooth interpolator, but anyhing integrated would be good.  I don't know if i'd use it, if its a linear smooth motion probably not.  I'm a stickler for stuff having some sort of inertia and such.

cheers and thanks for the quick respons

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #187 on: August 09, 2013, 07:52:08 AM »
besides a smoothpath I'm wondering how the a* tag system works.  If its similar to regular tags, perhaps the get nearest node should have a get nearest with tag sibling.

But actually, been fooling with this only for a week now, so not completely knowledgeable about the a* system.  So perhaps i'm stating something silly or noobish

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #188 on: August 09, 2013, 06:30:30 PM »
The smoothing system Im currently developing is not a simple linear interpolation. Instead I want  a system that hides the individual node positions by introducing a turn radius at each node that will only smooth those points which are normally an abrupt change of direction. The goal would be to preserve as much accuracy as possible, while still looking smooth.

And yes, it is possible to get the root of the pointGraph. I'll include it in the next update (which I'll probably release the day after tomorrow) with some more set and get options specifically for point graphs.

Tag system is the same 32 layer system as you'd know from the rest of unity, though implementing it seemlessly into PlayMaker could take a fair bit of time I think. I'll have to take a look at it soon, but I'll finish the pointGraph and movement stuff first I think. Though if implemented well, I think tags could be very powerful .
Best,
Sven

LoneCipher

  • Playmaker Newbie
  • *
  • Posts: 29
Re: A* pathfinding (stable 0v83)
« Reply #189 on: August 10, 2013, 02:09:40 PM »
Quote
0v83 changelog:

 unify speed setting in MoveTo for all controllers (so you can change the controller without having to adjust the speed setting) [done]
- make IgnoreY also work on the Finish Distance [done]
- fix rvo controller speed issues [done]
- add rigidbodyVelocity movement mode(sets rigidbody velocity to direction)[done]
- calculate ETA action (one of the benefits a unified speed setting offers) [done]
- stuttering issue if you duplicate an actor that follows [unfixable] you need to use a pooling system.
- bug if you delete one of many actors that follow [fixed]

The deletion issue is definitely resolved in the latest version. Thanks so much!

I set up PoolManager4 to spit out some prefabs and retested the jittery follow issue. I still see jittery movement when using follow. Am I still doing something wrong? :(


kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #190 on: August 10, 2013, 03:20:59 PM »
Glad it helped :D
Can you send me that scene? I can't see the jigger in the video. I have a license for poolmanager already.
Otherwise I could also create a test scene myself if you can tell me when exactly the jigger occurs. Does it appear as soon as you spawn a new actor? does it appear when your follow action updates the path?
Best,
Sven

LoneCipher

  • Playmaker Newbie
  • *
  • Posts: 29
Re: A* pathfinding (stable 0v83)
« Reply #191 on: August 10, 2013, 04:30:46 PM »
I can pack up the scene for you.
In the video, you can notice that the speed of the cubes slows as each new actor is spawned. If you highlight the actor as it is moving, you notice the highlighted path of the cube flashes. I imagine that each cube is sharing the same path and all cubes are updating it each frame.
This symptom does not occur when you check the 'auto' checkbox.

1 cube = full speed
2 cubes = half speed
3 cubes = 1/3 speed
4 cubes = 1/4 speed
5 cubes = 1/5 speed

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #192 on: August 10, 2013, 06:26:57 PM »
weird issue, yeah , quick fix : set the update interval to something like 10 . The speed seems to depend on the framerate, which is weird because I am using Time.deltaTime which should effectively make the framerate irrelevant. I'll look into this tomorrow. It is a very important issue...
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v83)
« Reply #193 on: August 11, 2013, 03:32:10 PM »
ok, yeah, everyframe follow mode really highlights the need for some good performance optimisations. I started it but it'll be a longterm project. Try using the new movement acion in the attachments, make sure to disable the log optio in the action and also disable the log option in the A* gameObject (AstarPath component). Debug log in unity can slow things down by a lot...
Please tell me if that helped, and if yes, how much.

(you'll also have to update the custom editor, but you'll find the right directory for it easily by just searching in unity's project tab)
Best,
Sven

LoneCipher

  • Playmaker Newbie
  • *
  • Posts: 29
Re: A* pathfinding (stable 0v83)
« Reply #194 on: August 15, 2013, 04:23:55 PM »
Sry for the late response.

The updated moveto actions work perfectly. I don't notice any difference in speed at all.
Nice work! :)