So I'm not sure exactly how to use pathfinding...
owen_dennis
Just a guy, you know.Member, PRO Posts: 236
I've looked at the cookbook and the GSInvention maze pathfinder and I'm seeing how paths are mad. However, I'm not actually seeing how to utilize the path after it's been made. How do you make, for example, an enemy spawned in a random location always try to go toward the hero actor, making its way around objects and such? The cookbook version is very much something turn based, but how about something realtime? Sort of a pac-man ghost?
It feels like it would have to be something where you spawn your grid, then have each grid box fill up a table with their x and y locations, then tell the enemy actor to go from one to the next or something?
Comments
ALSO also, I might be missing something here, but does this kind of pathfinding basically make it so you can't just spawn a number of new enemies that can all pathfind? Each enemy would have to use their own table for pathfinding, so you couldn't do something as simple as "every x seconds spawn new enemy" you'd have to do it the recycle way of "Every x seconds change a boolean, if that boolean is active then that enemy is active"
Or something... It just a lot to wrap my head around.
Vote for Nearest Neighbor Scaling option in gamesalad! Let's make our games look truly stunning!
Use a grid. Here is a method for calculating spots on a grid. Once you have that you can use table rows to extrapolate grid position based on column/ row number. http://forums.gamesalad.com/discussion/56974/free-snap-to-grid-tutorial-template-some-community-love
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Yep, but you are on the right track.
Each "path finding" actor needs its own table (our equivalent of arrays) specifying its path.
Sharing this table between actors is not an option, it is too slow if you need to recalculate the table for each actor in turn.
Also, you CAN spawn new enemies at any time, you just need to update the position of all your enemies in the main grid table all the time.
The tricky bit is reusing tables for all the spawned and killed enemies. GameSalad currently does not give us a way of adding/deleting tables.
You therefore need to have pre-existing tables for the maximum number of enemies on a level.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
Thanks guys. I think I got roughly how it works. It was very very hard to wrap my head around. It references like 5 different tables (the map, the x coordinates of walls, the y coordinates of walls, the path, and the enemy table showing where in the map the enemies are). I feel like there's a more efficient way of doing it, but I did finally get it working, so that's cool!
I originally wanted a smooth motion and I'm having trouble achieving that. However, when I saw this motion, I actually realized it would suit the needs of my game waaay better (a block-movement based game) so this is actually pretty great! Not sure what I'd have to do to make it a constant smooth motion, but I think I can figure it out at some point.
Vote for Nearest Neighbor Scaling option in gamesalad! Let's make our games look truly stunning!
Looks good man keep us posted, I've given up on this path finding stuff a few times but actually mite give it a go this weekend based on your progress
What behavior are you using for the movement?
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
The enemy actor makes a path to its destination. Then I have it start at row one, use the first column to tell me what row the x information is in in my x coordinates table, then the second row to find the y information in the y coordinates table. Then it uses a move to function to go to that location.
What I originally tried to do was that it would use the move to function, then when it reached that destination, it would switch to the next row down and use the move to function to go there, but it wasn't working. One version I tried it would just go to the location and stop. Another version it would sort of pass through walls and skip rows that it was supposed to be going to.
Eventually I just put it in a timer, and as I said, it'll actually work way better for what I'm doing than a constantly moving thing.
Every 3 seconds, Change the row, change the destination x and y, move to destination x and y.
Vote for Nearest Neighbor Scaling option in gamesalad! Let's make our games look truly stunning!
Really like the look, I'd agree that given the style, a blocky / stepy motion really suits it.
For a constant smooth motion I'd guess you'd interpolate from one position to the next ?
Nice! looks good for a couple days work. I need to give this feature another look.
Follow us: Twitter - Website