playMaker

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

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #150 on: May 09, 2013, 05:05:36 AM »
thank you all for your continuing interest in the plugin . I'm sorry I didn't update it recently, I'm preparing my oral exam and it took most of my time.

But for today I'll see if I can fix all the bugs etc. The gizmo issue should be rather straight forward.

@ Saputo
You can add a box collider to any tile (static colliders aren't all that expensive) and enable/disable it depending on the walkability of the tile. Then you can use UpdateGraph to update the area of the node . I'd recommend a use of a gridgraph which you specifically set up in a way that each node is directly on the center of a tile.

@SteveB
your installation seems to be correct if you use the pro version I think. If you use the free version it should work out of the box, just install Playmaker, and then my package (which already contains Astar).
And the example should have everything setup in a way that works. So I'd guess that Aron's package changed, I'll check it out today :)
« Last Edit: May 09, 2013, 05:18:48 AM by kiriri »
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #151 on: May 21, 2013, 12:22:08 PM »
Since I obviously can't continue this thing for now, here's the path error fix for now.
I won't make any promises to anything else since right now I'm living in a hazardous environment  ;)
Best,
Sven

jonjojo

  • Playmaker Newbie
  • *
  • Posts: 1
Re: A* pathfinding (stable 0v81)
« Reply #152 on: May 27, 2013, 05:54:10 AM »
Hi thanks for the brilliant extension,  i am still getting problems on the Tower Defense example even after taking the 3 new scripts.  When i click i get ...

NullReferenceException: Object reference not set to an instance of an object
FsmConverter.NodeListToArray (Pathfinding.Node[] go) (at Assets/PlayMaker/Actions/Addons/AStar/FsmPathfinding/helpers/FsmConverter.js:22)
getNodeInfo.DoStuff () (at Assets/PlayMaker/Actions/Addons/AStar/FsmPathfinding/getNodeInfo.js:101)
getNodeInfo.OnUpdate () (at Assets/PlayMaker/Actions/Addons/AStar/FsmPathfinding/getNodeInfo.js:107)
HutongGames.PlayMaker.FsmState.OnUpdate ()
HutongGames.PlayMaker.Fsm.UpdateState (HutongGames.PlayMaker.FsmState state)
HutongGames.PlayMaker.Fsm.Update ()
PlayMakerFSM.Update ()

Also there is a compile error in Mono

In getClosestPointOnPath.js  line 61

for (var i =0; < Enumerable.Count(pathNodes);i++)

it says "Ambiguous reference 'Enumerable':System.Linq.Enumerable, System.Linq.Enumerable

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #153 on: June 24, 2013, 05:32:31 PM »
Thanks for the amazing work!

When using "Move to", gravity (some form) is applied somewhere. This is great, as the Character controller is not providing this.

But it's falling too slow for me.

Can any one tell me where the "gravity" is applied, so I can speed it up? I cannot figure it out.

Thanks a lot :)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #154 on: June 25, 2013, 06:41:14 AM »
the gravity force is 9.81m/s^2 just like in reality. If it's too slow, it means your objects are too large. 1 unit in unity equals 1 m in the physics engine.
So the best thing would be to scale it all down to what it should be like.

Alternatively you can change the gravity value too. Use the SetGravity action which should already be included with PlayMaker.
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #155 on: June 25, 2013, 07:11:00 AM »
Wow - so simple :)

I thought the gravity was simulated.. well, erh, I know it is, but I did not think the physics engines simulation was used, since Rigidbody and Character controllers are not good friends, I figured you made some home grown math I could not find.

Thanks a bunch! Really :)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #156 on: June 27, 2013, 05:39:51 PM »
A lot of the Actions have an input field "Input Path", example:

Smooth Path
Game Object (That is self explaining)
Input Path: How is this supposed to work?

I do not seam to be able to create an "FsmPath" - how is that done?

Thanks.

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Jerky movement
« Reply #157 on: June 27, 2013, 05:49:29 PM »
I literally spend 3 days now trying to make smoothing ghost objects to get a nice move in my objects. They work, but always come with a second problem or two, as they also cause "follow behind real action" and "smoothing what should be hard". So now I thought I'd try and ask:

When just using "Move To", on a point graph, the forward motion is sometimes smooth, but then it has random jerks every now and then.

Is there a built in functionality to make straight movement non-jerky?

Thanks.

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #158 on: June 28, 2013, 06:45:11 AM »
after creating an object variable, you can select it in the PlayMaker variable tab and define its' type. You should see a category called FsmPathfinding. In there should be all the additional variable types the pathfinding actions require.

As for the jerkiness, can you create a video of it? without seeing it I can't help you I think.
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #159 on: June 28, 2013, 09:28:07 AM »
Sure, here is a screencapture of a test maze:


I could set this up in many ways of course, and here the white box (Astar) is doing raycasting to ground and other stuff. But the same result is seen if I only take 2 completely similar objects, let one of them move by other means, and one by Astar.

In the video the camera is following the other object to show "who is stable": If I let it follow Astar, it's harder to tell what is going on, because the whole game will be "a little jerky now and then".

I have tested if this is happening at special nodes or what ever, but it appears that it's random.

In all fairness I must say that the screen capturing and Youtube transferring did not exactly help - it's not that bad in reality, but it's pretty unsmooth, and has sudden jerks every now and then.

I'm excited to hear what you think :) Thanks!

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #160 on: June 28, 2013, 10:19:03 AM »
And for the FSMPath object - OH! Thank you very much, a new world just opened to me.

Thank you!!! Wow :)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #161 on: June 28, 2013, 01:09:48 PM »
hmmm, I haven't encountered jerkyness like that myself, so I guess it could be the pointgraph itself. How did you create it? Did you have a look at the path to see if it perhaps sometimes turns direction for 1 node or so ?
Or perhaps the jerkyness appears when you update the target location of the moveTo action (when you reenter that state) ?
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #162 on: June 28, 2013, 03:50:03 PM »
Hmm.. I have not encountered that much jerkyness either - but I was happy to see how screen capture and YouTube exaggerated my point ;)

In reality I have often thought there was zero shake, I have been watching happily for many seconds, and then all the sudden there it is again - that sudden jump - at random spots.

I have it with any graph type that I have tested. I am pretty sure you have it as well.

I started by not noticing, because I did a standard setup of the AI moving about and maybe even the camera following it.

Then I wanted to fine tune my basic setup to be "smooth as Mario", and from there on I started to notice something was wrong.

First I thought it was somewhere else, as the character was steady, it was more the whole game that made little jumps here and there.

It is only when I make something else very smooth that I realize how unsteady the Astar Move To really is.

The planned game is for mobile devices, where the user is supposed to do little that does a lot - just swipe to change direction, tap to jump.

And in such a setup the AI is the main character, and then one start to see the problem - either the game track is jumping now and then or the character is - depending on how the camera is set up.

I am not much of a coder (thanks lord for Playmaker ;) but my humble guess is that the code keep requesting simplemove to new directions - also when not turning.

While this works most of the time, sometimes there's a set of calculations done in the wrong order, and 2 moves is happening in one frame and 0 in the next.

This is why I wondered if there's a better way - something more along the way iTween Path does things, or maybe a way to catch the calculations a little beforehand and do some smoothing over a couple of cycles.

I can do the latter in "post" but my problem is that the character controllers collider is then placed in front of what is seen as smooth.

And it's also a problem that no sudden stops are possible then (landing firmly on ground, not soft landing on a pillow of air).

This could be solved by accepting jitter on Y axis, and letting the Z&X be pre-smoothed inside the code.

unfortunately I am not a programmer :/

Cheers, and thanks for all you have done :)

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: A* pathfinding (stable 0v81)
« Reply #163 on: June 28, 2013, 04:24:31 PM »
hmm, this is very weird, no matter what I try, I can't replicate your bug. I sometimes get jerkyness with the local avoidance  controller, but never with the character controller. I will sleep over it and look into it tomorrow. I also need to fix the example scenes so I'll try to do both at once...
What I do know is that a "double simple movement" in one frame is not possible, and there is no way my code could do that anyways, so it must be something different. Using something like iTween for the movement would not take Physics into account, so it's a bit difficult.

Let me think about it :)
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
Re: A* pathfinding (stable 0v81)
« Reply #164 on: June 28, 2013, 04:35:38 PM »
A single output to a (global) Vector3,

And a double input (Bool + Vector3) to say "We collided here, start here with what you are told to do" (move the other way back, or continue through because in reality I have jumped across or destroyed the obstacle) would solve all my problems!

In fact my only reason not to be able to fix things myself is that I am dependent of the character controller.

if I could get raw data (Vector3) of where the "ghost" was, I could smooth out and place anything at that vector or part of it. And if I collided, I could tell the Astar to stop and "reset" at the Vector3 I gave it to start over from.

I know this would take some documentation to understand for everyone else, and I'd be happy to write this.

it would also mean that one could chose any type of object to follow the path - fish and planes, here we come, like Mario, here he comes as well.

Another benefit would be that one could "terminate on the spot", move around and start over the Astar quite easily.

Bool: Move / Do not move
Vector In: Where to start from when Bool is set to 1
Vector Out: Where "ghost" is at

Cheers,

Frits