playMaker

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

kolchaud

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: A* pathfinding (beta)
« Reply #30 on: January 14, 2013, 10:42:16 AM »
Considering that CalculatePath() method is called too many times, when target moves, I add a tolerance test on OnUpdate method.

On my smartphone it works very well :)

Here is my modification :

Code: [Select]
if (target.Value != null && /*target.Value.transform.position != targetPosition*/ Vector3.Distance(target.Value.transform.position,targetPosition) >= targetTolerance.Value)
{
if (LogEvents.Value)
Debug.Log ("Target was specified, getting position.");
CalculatePath();
}

where targetTolerance is defined like this :
Code: [Select]
public FsmFloat targetTolerance;
I've attached the action file. 

Hope it will help for mobile projects.

Ahnwee

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: A* pathfinding (beta)
« Reply #31 on: January 16, 2013, 08:04:05 AM »
Code: [Select]
Assets/PlayMaker/Actions/Addons/AStar/FollowPath.cs(96,64): error CS1061: Type `System.Collections.Generic.List<UnityEngine.Vector3>' does not contain a definition for `Length' and no extension method `Length' of type `System.Collections.Generic.List<UnityEngine.Vector3>' could be found (are you missing a using directive or an assembly reference?)
I was very excited when I found that you lovely people have made a start on some PlayMaker actions for A*, but I can't seem to get the package to work for me. Could someone tell me why I get this error?
Aaron's A* appears to be working for me, and I'm trying this on a relatively clean/new project so I don't think its a conflict with anything.

I know this is a question likely to have a very simple answer, but I'm just a very simple kid trying his hand at some Unity.

Cheers

(PlayMaker 1.4.(3?), Unity 4 Free)

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: A* pathfinding (beta)
« Reply #32 on: January 17, 2013, 03:51:42 PM »
@ Carwash
This is plain weird, I define the function in the same script... It should not be unable to find it. I've just downloaded the package and imported it together with playmaker 1.43 and the latest version of A* into unity 3.5 on windows . The only warning is an obsolete variable, which is not at all bad.
Could you tell me if you still get the error after importing it into an empty project? Else you can just delete the script, it's just an action and not vital.

I'm on Unity 3.5.6
I had an old version of A*, so downloaded the latest (3.2.3).
Installed A* first, then playMaker (1.4.5), then AStar Beta 0v6. Got a different error message, something about 'length' not being defined (I'm not at home atm, so can't C&P). After deleting that script, I got the same error message in a different script, and I can't see any A*/ pathfinding actions in playMaker :(

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #33 on: January 18, 2013, 06:52:37 AM »
 noted!

After some resarch I found out that some things were "fixed" in aaron's pathfinding, which includes lists etc. So the newer versions of his package don't work anymore. But I can fix it I think.
Let's see in an hour or so.
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #34 on: January 18, 2013, 07:19:27 AM »
ok, to fix this, replace the line in question (l.97 in the FollowPath script) with this:
Code: [Select]
if (currentWaypoint >= (path.vectorPath as Vector3[]).Length) I have no idea what it thinks the list is, as unity says it is a vector3[] , but if we tell it explicitly that it is really a Vector3[] , it works again.
There's likely a typo somewhere in the new pathfinding package I'd guess. I'll post the script in the start post, please tell me if this fixes your problems. It did for me anyways.
Best,
Sven

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: A* pathfinding (beta)
« Reply #35 on: January 18, 2013, 01:10:16 PM »
I now get
Quote
Assets/PlayMaker/Actions/Addons/AStar/FollowPath.cs(97,65): error CS0039: Cannot convert type `System.Collections.Generic.List<UnityEngine.Vector3>' to `UnityEngine.Vector3[]' via a built-in conversion

I tried editing the script myself (the line was on 96 in the script I had), and have downloaded the script in the original post to try (where I see it's on line 97). Both ways give the above error.

I restarted Unity several times whilst trying this fix.

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #36 on: January 18, 2013, 02:43:44 PM »
weirdest thing, I emptied the project and reimported everything exactly how you described it , and I finally got the same error. The problem here is that the type of the list changed. Instead of .Length we now need .Count .
I'll be fixing up a WIP version in a moment.
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #37 on: January 18, 2013, 03:09:41 PM »
Ok, just please tell me it works now for everyone. You will need the very newest version of aaron's pathfinding, this is not compatible with any of the older versions. There were major changes in very fundamental functions, which caused the actions to almost all be outdated. I do not understand why it only showed the one error, but after fixing that it took me on an odyssee of other bugs :S
Please only use the actions that you know from 0,6 (see first post for the list), as the rest of them is still heavily WIP.
Best,
Sven

Carwash

  • Playmaker Newbie
  • *
  • Posts: 11
    • View Profile
Re: A* pathfinding (beta)
« Reply #38 on: January 19, 2013, 04:06:00 AM »
Excellent work, Kiriri, thanks. It all imports with no errors now, and shows up in playMaker!

Ahnwee

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: A* pathfinding (beta)
« Reply #39 on: January 19, 2013, 05:49:26 PM »
This has fixed it for me! Nice work :D

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #40 on: January 21, 2013, 02:36:51 PM »
great, now that this all works, here's the next update.

There's good news and bad news.
The good news is that I've extended the system greatly. I switched to javascript, which allows us to actually use object variables in our scripts as input. The wrappers I created can be plugged into most actions now. While this has certainly become more complex, it is also exponantially more powerful. Let me know what you think of it (I think this would be the first PM plugin that uses object variables directly).

The bad news ist that this is not backwardscompatible.... You will likely have to manually reproduce your FSMs so far. For me that took about 45 minutes, which is fair considering the new features and potential I think. Even so, I'm sorry this reformation comes so late. Beta should not be so irradical.

I've never been good at documentations, and right now the code is a mess, especially since I played around to find ways to make the warnings disappear. I also implemented some fixes regarding previous problems like the followTarget action. Have a look at them and tell me what you think.

As far as the changelog goes, there you go, if incomplete :
0.7 beta
- get node info
- removed unneeded warnings and added thrice as much necessary warnings
- check area walkability individual
- wrapper variables
- createPathTo (advanced and js version)
- followPath (advanced and js version)
- translatePath
- getPathInfo
- getNodeInfo
- getNodeFromNodes
- autoMove helper script for movement even if the action is not active.
- Debug paths options
- smooth path action
- ported all the rest of those scripts to js, if they use any object variables (yes, I'm too tired to list them here :D)
- ... lots and lots of small changes and additions. I really couldn't keep track of them all but I think I addressed everything mentioned in this thread before. Hope everyone's pleased :)
« Last Edit: January 21, 2013, 02:46:19 PM by kiriri »
Best,
Sven

Uttpd

  • Junior Playmaker
  • **
  • Posts: 66
    • View Profile
Re: A* pathfinding (beta)
« Reply #41 on: January 22, 2013, 05:14:06 AM »
Thanks for the great work.

zoeyun520

  • Playmaker Newbie
  • *
  • Posts: 12
    • View Profile
Re: A* pathfinding (beta)
« Reply #42 on: January 23, 2013, 01:21:12 AM »
Does it support  IOS?

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (beta)
« Reply #43 on: January 23, 2013, 01:26:11 AM »
Yes, though mobile devices do not support as many paths as the desktop version. But as long as you don't calculate more than 100 paths per minute, there shouldn't be any noticeable difference. At least there isn't on android.
Best,
Sven

PIXELCRY

  • Playmaker Newbie
  • *
  • Posts: 30
    • View Profile
Re: A* pathfinding (beta)
« Reply #44 on: January 23, 2013, 02:31:53 AM »
i use last version in assets store A* pro 3.1.4, i tried restart in  unity 3.5.6 and 4.0 but both give me this error:

Assets/PlayMaker/Actions/Addons/AStar/Wrappers/FsmABPath.cs(8,24): error CS0246: The type or namespace name `ABPath' could not be found. Are you missing a using directive or an assembly reference?


 :-[