playMaker

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

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v84)
« Reply #225 on: September 18, 2013, 10:10:40 AM »
glad it works now :) Though this is none of PlayMaker's faults ;) The astar plugin calculates all of the paths etc at the end of the frame together, that way it saves an incredible amount of performance. It really is the best way to do this I think, it's just that I haven't gotten around to finishing the tutorial I wanted to do for like forever now , so how should you have known that  :D

I'll release the 0v84 now, I did some bugfixes and it should work better than it did before, but I didn't take notes so I forgot what exactly I did :D Since there's apparently no mac users, I'll just ignore the mac support question until someone complains here :D

Please note that I updated the setup video. I also plan to update vid nr. 3 and continue the series. But don't take my word on the "continue" part :P

https://docs.google.com/file/d/0B45ng4mYiP6ZN3JlMFpNeXAxRXc/edit?usp=sharing


Release notes :
- Installer/Updater/Pro Updater script [done]
- GetNodeInfo now features a graph shortcut [done]
- Get Set Graph Info : Custom Editor and custom output for PointGraphs and GridGraphs [done]
- fix jigger/slowdown issue on follow mode and then unify the speed settings again... [done? at least better now]
- smooth turns option [done, needs perfecting for follow]
- replace all regular distance calculations with sqr dist where possible, to save performance.[done]
- Added speed output variable to the movement action [done]
- Absolute Endnode now takes IgnoreY into regard [done]
- Absolute Endnode now works without a target GameObject [done]
- fixed errors that made the action finish before even really starting (not clearing the previous path) [done]
- fixed WalkabilityInArea... this broke sometime, dunno when :S [done]
- added flee, fleeContinuously and random mode to the movement action (these are much faster than the normal movement actions if you're using pro. On free, they are the same as the normal movement, because I didn't want to undermine aron's pro package and I therefore didn't even try to create something more fancy. Still, this should be useful even for free users :) )[done]
- add "shadow" movement mode. This will be a very cheap way to follow a target. It will only calculate the path to the target once, and then add the current target position as a waypoint every frame, if it moved.
« Last Edit: September 18, 2013, 11:18:55 AM by kiriri »
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #226 on: September 20, 2013, 06:50:18 AM »
Hi i'm trying out the 84 build..  Noticed a few minor issues..

Most importantly, my pathfinder object using a moveto (or shadow when I tried it out)  Is beelining for 0,0,0  once arrived it will actually start to properly pathfind.   

As i'm spawning at different locations, I now get all my units needing to touch 0,0,0 before returning to the actual target position .  At first I.  thought I placed my pathfinding game-object wrong,  but it actually starts at its spawnlocation, smoothly straightline moves to 0,0,0 and after that does its thing correctly. (but not before starting a premature all out war between my units:)

My guess would be that the smooth motion start or target position vector3 is set to 0,0,0 and not to the current position of the game object, and its interpolating to 0,0,0 first.  Dunno just a guess, I'll look at your code a bit, see if its something i'm doing wrong, or something like that. (always mistrust yourself first;)

And minor issues:
1. You manually to remove the old version folder(install created a backup version folder I guess), or duplicate script error
2.There's some 1 and 2 debug logs in moveto.js , causing a lot of framedrops when doint a lot of moveto's  .

For the rest it seems to run smoothly enough,  but with the startup behaviour flipping out, I haven't been able to play around with the smooth turns feature (dying to try it out, its a rout to deleting a big chunk of my crappy code). 

anyways , thanks for updating and iterating, its really appreciated. 
Tomas

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v83)
« Reply #227 on: September 20, 2013, 07:04:35 AM »
On a second look, I think i've scripted my units wrongly,  I looped the moveto back to itself after a failed or finished event, to create a continues follow.  But, that causes them to haywire and head for 0,0,0 at the start.

Gonna see if I can try and script a bit more properly.. and if that  fixes it..
-------------------------------

Aah yes just removed any finished or failed events, and that seems to have fixed it..  Using shadow still just causes my units to sometimes still beeline to their target, its sort of weird. 
« Last Edit: September 20, 2013, 07:14:28 AM by muppetpuppet »

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v831)
« Reply #228 on: September 20, 2013, 07:26:47 AM »
Thank you for your feedback, I value it a lot.
I agree that immediate looping back during the update phase of an action might potentially lead the actor to walk to the world origin. I cannot think of a fix for this though. It's generally for the best to never wire up the failed event with the same state again as right now failing really means somethings wrong with your graph or your action setup.

Well then, as for the debug logs, my bad, I'm still working on the follow mode which sometimes stutters if the next waypoint distance is less than the sqrt or the node distance * 2. I now removed the debug logs which were really only for my benefit.

I also noted that the current speed output was not available, I fixed this.

I don't quite understand your point about the setup though. I manually remove old files because I do not want to override additional scripts you might put in there. Then if you press any button at the end of the setup, it should remove the installer folder, so there shouldn't be any duplicate scripts there anymore. It's just the installation folder (with no scripts inside) that I can't delete.

The shadow beeline thingy is quite severe though... Can you have a look at the path? Does the path at least look fine or does it too go straight to the target? The shadow action should only add the current position of the target as a waypoint at the end of the path, every kind of movement along that path should work in exactly the same way moveTo of followPath does.

0v83.1
https://docs.google.com/file/d/0BwrgibYeepavZ0o0ZmNpWE9lRTg/edit?usp=sharing
« Last Edit: September 20, 2013, 07:31:16 AM by kiriri »
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #229 on: September 20, 2013, 08:54:53 AM »
Hmmm I had a FSMpathfinding subfolder in the version folder after finishing the install.  Could be just something i did wrong.. The original install folder also was still there,,  but I use dropbox , so it could have been claiming the files, forbidding deletion.

I've attached a jpg of some units with the shadow setting,, same unit-script  follow the path correctly with follow,  As you can see the path itself is straight, but somehow  all the paths only have two points.  (that could also be the problem I guess.)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v841)
« Reply #230 on: September 20, 2013, 09:05:07 AM »
If dropbox is claiming the files then there's very little I can do... I hadn't expected this, I should be able to catch that error message and print a message like "Folder deletion forbidden, please remove the installation folder manually" in the setup though, that should at least warn people ;)

Thank you for the shadow thingy, I know what's happening, I just don't know why it's that way : Your path is not getting calculated. What your seeing is just the "shadow" mechanism which always adds the target position as a new node if the last waypoint on the path is more than a certain distance away from the target position.

This is probably due to your path calculation taking more than 1 frame, I had a similar problem a while back with the follow action. I should have a solution this evenin I think.
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #231 on: September 20, 2013, 09:07:33 AM »
cool,  the units targets are updated only every few seconds or so,  so a shadow so  should improve performance a bit,, (already running at 70 fps avg on nexus 7 II though, but faster is always better)

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #232 on: September 20, 2013, 09:27:34 AM »
Perhaps you could also tell me what is happening with the smooth turn, if I turn it on (with the follow)  I get the following error:

Code: [Select]
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Collections.Generic/List.cs:633)
MoveTo.OnUpdate () (at Assets/PlayMaker/Actions/Addons/AStar/FsmPathfinding/moveTo.js:564)
HutongGames.PlayMaker.FsmState.OnUpdate ()
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.Update ()
PlayMakerFSM.Update ()

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v841)
« Reply #233 on: September 20, 2013, 09:37:18 AM »
Hmm, that seems to be my fault as well, it means that the waypoint your actor is walking towards does not exist (eg there are 12 waypoints in your path and you're aiming for waypoint 13 :D )

Can you tell me your next waypoint mode and movement mode ? That will make it easier to see where I forgot to clamp the currentWaypoint variable.

Oh and sorry for the abundance of errors, There's so many combinations of properties and modes that by now I find it very hard to test it properly, and since I didn't get any replies on my RCs I thought it would all work :D
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #234 on: September 20, 2013, 03:52:02 PM »
Hi, took a bit..

here's a screenshot of my settings.

hope it helps..

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v841)
« Reply #235 on: September 21, 2013, 06:11:43 AM »
I'm trying my best here but I can't seem to reproduce your errors. I copied your setup to the numbers and I made sure to check it on a pointgraph because I thought that might perhaps cause it (you know, if the initialisation of the point graphs could have happened after the movement actions start) , but it all seems to work just fine...

Have you tried having your actors wait before calculating their first path? Do they also beeline if you restart the FSM (disable, then reenable the fsm component) during runtime?

If none of that works, it would be nice if you could send me an example scene. Anything that creates an involuntary beeline would suffice :)
Best,
Sven

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #236 on: September 21, 2013, 06:18:01 AM »
Let me try out some things, I've got some additional weirdness like units hopping to their destination, right after enabling the FSM  containing the fsm..  So i'm thinking its something in my code or A* init. (which happens a looong time before the units are spawned).. I've played around with the A* settings, maybe i've broken somethings;)

muppetpuppet

  • Junior Playmaker
  • **
  • Posts: 77
Re: A* pathfinding (stable 0v841)
« Reply #237 on: September 21, 2013, 12:07:48 PM »
I think i've found out what i'm doing wrong, I start the state with an immediate target.  I've changed it so the pathfinding always has the same follow target, and I move that target around from only after 1 frame of pathfinding has concluded.. This stops all my startup bugs..  But still can't use shadow or smooth turns..

Could it be something in the A* heursitic settings?

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: A* pathfinding (stable 0v841)
« Reply #238 on: September 27, 2013, 10:44:38 PM »
Hi Kiriri,
I am just discovering Playmaker and A* so I wanted to give a try to your actions.
I have been through the whole thread tonight and I am amazed with the energy you invested in this projected.
I would love to implement you actions in my project but I can't nail  it properly.
First of all I regret the lack of proper documentation as I don't really understand the difference between many move modes ( follow and follow to for example) and many many great actions you have made.

My main concern is that it seems that the failed event seems to be broken, as it never fires.
Maybe my setup is not right, I don't know.
I have some kind of click and point control and if I click on an unreachable area the character will reach the closest point and start to jitter instead of failing.
There are some other time that stuter happends in the movement.

Also the smooth turns seems to crash unity when running the game.
I tried a setup with a create path state then a smooth path sate and then move to / follow to but it seemed to have a lot of bug as well.

I'd love to help but I am not so much of a coder, maybe I can help with the documentation ?
I hope you can find a fix for these or maybe it's just me who missed something.

Any way, Cheers !!

« Last Edit: September 27, 2013, 10:56:03 PM by Yanifska »
Visit my portfolio: http://www.yanivcahoua.com/

Yanifska

  • Full Member
  • ***
  • Posts: 163
    • My Portfolio
Re: A* pathfinding (stable 0v841)
« Reply #239 on: September 27, 2013, 10:59:48 PM »
After playing again with the perfect finish option it seems to stop the jitter but then the pathfinding is not so good, he wont reach the other side of the obstacle for example.
Visit my portfolio: http://www.yanivcahoua.com/