playMaker

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

FritsLyn

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #165 on: June 28, 2013, 02:26:38 PM »
Just did some basic testing:

Any positive collision testing on an object makes it do the jitter! (not just Character controllers)

I have 2 cubes moving alongside each other.

One is constantly doing so because it has "trigger stay"
The other is just doing so by adding to value and setting position.

One is jerky, one is smooth.

So basically to get silky smooth moves, one has to have a "ghost" to do the hard work and jitter itself as much as it want, read the place it's at from the other, and smooth place it.

The good news is that there is no jitter when just "asking if there's collision", so the "follower of the ghost" can still check if it hits something, and then send this info to the jittering ghost which then can re-place itself at the masters place.

So.. it'd work :)
« Last Edit: June 28, 2013, 02:43:19 PM by FritsLyn »

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #166 on: June 29, 2013, 02:26:18 AM »
you can actually do that already, you are not dependent on the character controller. It's a bit more complicated than a single action though.

You could start of by using the "Create Path To" action and saving the path to a variable. Then you can use the "Get Path Info" action to get the Nodes of that path. Then you can set an int variable called "i" to 0 ("Set Int"). Then in a new state you can do something like this:
"Get Node From Nodes" with the index i and save it to Node.
"Get Node Info" on Node and get the position as NPos.
"Get Position" on Owner and save it to Pos.
"Vector3 Operator" NPos - Pos = Direction.
"Vector3 Normalize" on Direction
"Vector3 Multiply" Direction * MovementSpeed.
(continue to the next state)

"Int Add" i + 1.
"Add Force" Direction on the Owner every frame.
"Get Position" on Owner and save it to Pos  every frame.
"Vector3 Operator" NPos - Pos = DistanceVector every frame.
"Get Vector Length" DistanceVector to Distance every frame.
"Float Compare" if Distance < MinDistance go to the previous State every frame

(Don't forget to expose and fill in numbers for MinDistance and Movement Speed)

With this setup you can use a rigidbody which allows you to just add your jump movement as a force. I've used Rigidbodies myself before as character controllers, they work great if you tweak them right.
I will update the actions so you can freely choose between using a characterController, a Rigidbody, an RVO controller, nothing, or whatever is on the gameObject already. That should satisfy everyone I think.
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #167 on: June 29, 2013, 02:59:08 AM »
Fantastic - I was starting to build my own modular Magic Boxes..



But I'll wait and see how this thing of yours shapes up, I'd much prefer that :)

Thanks!

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #168 on: June 29, 2013, 06:55:25 AM »
alright, first let's see if any of the new modes fixes things (or makes them worse).
Replace the MoveTo script in PlayMaker/Actions/Addons/AStar/FsmPathfinding/ with this new one. Then go through the controller types and check how it's working. Remember that each needs a different speed setting. If the speed is too high , they won't work (especially the transform). I'm still working on the rigidbody part. I'll try to find a solution to them sometimes looping back if they move quickly.

EDIT: Oh and if you haven't already, make sure to check whether upping the "Next Waypoint Distance" helps with the jitters.
« Last Edit: June 29, 2013, 08:46:52 AM by kiriri »
Best,
Sven

FritsLyn

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #169 on: June 29, 2013, 01:10:24 PM »
You Are A Freaking Hero, Sven!!!

First I tested RigidBody, to much amusement  - It's like it keeps adding force, funny results, might come in handy, I only tested short.

THEN I tried Transform.. S-M-O-O-T-H-!-!-!

And with Direction out -> Smooth look at direction.. VOILA!!

Awesome!

I'll play around with the other controller types just to see what lies in there - but that is only for the testing and fun.

.. Just tested some more - this is absolutely awesome!!

Very nice job, thank you, thank you, thank you :)

Thank you!

FritsLyn

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #170 on: June 29, 2013, 01:30:02 PM »
(Thank you)

FritsLyn

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #171 on: June 30, 2013, 12:34:03 AM »
Woops - Working with Transform, starting in the negative world, crossing 0.0.0 .. erh no, stuck. No crossing from negative to positive.

No problem to avoid, I moved my world - but thought I'd let you know.

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable 0v81)
« Reply #172 on: June 30, 2013, 02:54:00 AM »
:D I'm glad you like it. The stuck issue was caused by the new finishDistanceMode "absolute" (the rest of them should work in negative space too). I fixed it and added a new mode called "absolute Endnode" which I need for my own game. As always, the tooltips should explain all the modes.

Edit: The next update will be warning-free btw. :)
« Last Edit: June 30, 2013, 03:59:35 AM by kiriri »
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable, no warnings 0v82)
« Reply #173 on: June 30, 2013, 10:48:02 AM »
ok changelog, I'm not sure what I did in the last months, but I do remember what I did in the last days.

Changelog 0v82
-Removed ALL warnings (yay ! :D)
-Unified the movement actions into MoveTo *
-Implemented a Custom Action Editor for the MoveTo action.
-Added Movement Modes : Rigidbody, CharacterController, RVOController, Transform, Available, None (for custom controllers)
-Added Finish Distance Modes (to control which distance the Finish Distance attribute controls) : Absolute Endnode (actor to endnode), Absolute(actor to target), relative (along path), last (only start measuring when reaching the second to last node)
-Added MoveMode : MoveTo, FollowTo(new, like Follow, but finishes when it reaches the target), Follow, FollowPath
-Fixed the example scenes (put some effort into the local avoidance and it now works decently too)

*I'm not sure you guys will be happy about that, it means you'll have to update all your Fsms that used movement actions before. However, from a developers perspective this was overdue. Due to certain reasons I can't program actions for PlayMaker like I would other scripts. Instead of inheriting certain code from one script, I had to copy paste the same code snippet into each movement action each time I made a change. By unifying the movement scripts I save myself a lot of time both when bugfixing as well as when developing new features. I hope this doesn't annoy you guys too much.

Free :
https://docs.google.com/file/d/0BwrgibYeepavZFJ5OFZFR1htRWM/edit?usp=sharing
Pro (the examples aren't working in pro so I removed them): https://docs.google.com/file/d/0BwrgibYeepavQzk3RmQ1ejZOWjQ/edit?usp=sharing
« Last Edit: June 30, 2013, 10:53:08 AM by kiriri »
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (v821)
« Reply #174 on: June 30, 2013, 12:57:29 PM »
a very small but important update : With this package I've removed the need for pro users to rig their AstarPath.cs file. There is no need for it anymore, as I've changed the function in a way that makes it work outside of AstarPath. So yeah, I'll just call it 0v821 :D
« Last Edit: June 30, 2013, 01:03:37 PM by kiriri »
Best,
Sven

LoneCipher

  • Playmaker Newbie
  • *
  • Posts: 29
    • View Profile
Re: A* pathfinding (stable 0v82)
« Reply #175 on: July 26, 2013, 10:32:05 AM »

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?

Gua

  • Full Member
  • ***
  • Posts: 180
    • View Profile
    • Andrii Vintsevych
Re: A* pathfinding (stable 0v82)
« Reply #176 on: July 28, 2013, 11:31:46 PM »
Thx for the actions! Is there a hope for actions description and more tutorials?

Hm.. when I scan red cubs do not disappear, but it does generate nodes.

Can someone tell me what am I doing wrong when trying to install pro version?


p.s. Ive noticed that Astar Beta 0v821 pro weights only 51 kb, is it normal?
« Last Edit: July 29, 2013, 03:03:46 PM by Gua »

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable 0v82)
« Reply #177 on: July 30, 2013, 03:04:44 PM »
hey guys, sorry for the late reply, I just started my 5 weeks GB tour and I didn't have any internet for the first week. Right now I'm at a youth hostel and it blocks this site as it labels it a "gaming" website, so I had to use a proxy to even see your replies :S

As for the deletion-stuttering issue, yeah that is quite an annoyance that's been bothering me as well. But I didn't notice the deletion error (I use pooling). Fixing that has very high priority for me, so I'll try to do it within the next days or so.

@ Gua
You're welcome, I'm glad you like it so far.
First of all, scanning should update all your nodes. It should not add new nodes. Red cubes only appear if the node there is unwalkable. To make sure a node becomes unwalkable on scan, check the AstarPath settings (yknow, the thing that I always put on an A* gameObject. ) You may have forgotten to include whatever should be unwalkable in the collision layer.
Right now the pro version only contains the PlayMaker actions and not the actual A* addon itself (because obviously I can't just share that freely) so it's much smaller. Also, what I forgot to mention in the update instructions is that you should make sure that your old project does not contain any of the astar-PlayMaker files because they may no longer exist in the new version. So in your case the FsmABPath.cs file no longer exists in the new astar plugin and therefore was not overriden. Now it references to a different script and expects for that script to contain the informations it needs. However , that script was updated and no longer contains the information, so it's throwing an error. So in short what you need to do is 1) create a backup of your project and 2) just import the new astar pro and the astar pro actions. Then remove all the scripts that throw up errors :D (At least I think this should work, I'll test it tomorrow myself, but I've done some changes to the package that should allow for such a simple update).

More tutorials... good point, will likely not happen within the next 4 weeks, not even in text form, It's just too difficult while being on the road. But afterwards I really plan to pick it up on a bigger scale again. That is why I really appreciate all you people who give me their feedback here on the forums. It's what keeps me motivated :)

So yeah , hope that helped. If you have more problems or if this didn't help, feel very free to post it here .
Best,
Sven

Swifty

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: A* pathfinding (stable 0v82)
« Reply #178 on: July 31, 2013, 04:51:03 AM »
Thank kiriri for all your hard work. The actions are really helping me set up A*.

I have been trying to output the path form MoveTo and then use GetPathInfo to get the path length. However, MoveTo does not seem to output a Path. I am trying to put the path into an FSMObject variable of type FSMPathfinding.FSMPath.

Any ideas on what is going on here?

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: A* pathfinding (stable 0v82)
« Reply #179 on: July 31, 2013, 01:24:59 PM »
the problem with the paths is that they are not immediatly created . Instead they are queried to avoid frame lagging. So if you first use a move to action and then a getPathInfo, the moveTo action will likely not have created the path yet. If you use a moveTo action and wait a frame and then use the getPathInfo though, there is a good chance it'll be done.

For cases like yours I added the createPath action. Just use that first and hook up the FINISHED event. then in the next state you can use a moveTo action (in follow path mode) and also access all the path properties, because the finished events makes sure the path is finished. I can look into more immediate path creation (actually I will, it sounds useful, even if it could slow down the fps), but right now I don't have the resources to go through aron's code and figure out how it could be done properly. I put it on my listfor v84 though :)
« Last Edit: July 31, 2013, 01:40:19 PM by kiriri »
Best,
Sven