Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [3D} A* pathfinding, Place 3D Objects, Mouse Click/Touchscreen Movement

Author
Message
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 30th Jan 2018 23:41
I wanted to share this demo with everyone. For a newb, its some of the hardest concepts(imo).

A* pathfinding was taught by https://www.youtube.com/watch?v=-L-WgKMFuhE&t=341s. I love this guy. I also learned a ton about blender from watching him. He has a lot of great videos, but a lot of it is over my head.

The code for the mouse coordinates came from herndon(sp?).
The WrapAngle came from StabinTheDark.

Press the spacebar to place more boxes. Click mouse to drop the box. You will not be able to place multiple boxes on the same location. The default node size is .5. Meaning, the player moves in .5 increments(or close to it).

Attachments

Login to view attachments
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 31st Jan 2018 09:00
OMG, Thanks...that is superb!!!!
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 31st Jan 2018 09:37 Edited at: 31st Jan 2018 13:53
Hi

thank you very very much !
it's amazing and very usefull !!

Thank a lot

Edit : do you know how I can select an object (to move/delete/rotate... it) ?

Edit2 : ok I have found to pick an object


AGK2 tier1 - http://www.dracaena-studio.com
hoyoyo80
8
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 1st Feb 2018 00:02
Can this work on non flat level like terran,stairs etc...

Ps: Anybody know 3d waypoint tutorial? Thanks
puzzler2018
User Banned
Posted: 1st Feb 2018 21:37
Great resource
https://www.youtube.com/user/shiffman

As a* in his tutorials, ok he uses Java PS5 but can be very easily transferred to AppGameKit with some conversion knowledge, but he is excellent
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 3rd Feb 2018 03:28 Edited at: 3rd Feb 2018 03:30
I need to add something to increase the speed. I have it capped at 100 "test" steps. I changed it to 125, and there is a short noticeable pause on the more complex paths.

For instance, moving to the X I get a slight pause before he moves. However, any other position he moves instantly.

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 3rd Feb 2018 08:24
Hi
Is the door a collision object ?
How do you do to know that you have to open it when the character is near this door ?
AGK2 tier1 - http://www.dracaena-studio.com
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 4th Feb 2018 17:42 Edited at: 4th Feb 2018 17:46
If he gets close to the door, it will open. Just a basic distance test(I use the absolute value for difference in X and Z since I have read square root calcs are too taxing).

The door isn't a collision object when I test for "hits". I turn the collision off for doors, floors, etc, then turn it back on.
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 9th Feb 2018 16:26
Hi

I have aquestion : in your astar example, how do you do to move an object in y axis ?
I havent found how to do that ^^.

Thanks
AGK2 tier1 - http://www.dracaena-studio.com
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 9th Feb 2018 17:21
The example is for flat surfaces. I have not researched how to adjust for height.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Feb 2018 16:21
If your terrain is uneven it's still a 2-dimensional surface, at least according to the algorithm. Games like Age of Empires will slow character movement uphill. This is turn can make some paths take longer to travel, even if it's a shorter distance, You can take elevation into considering by adjusting the heuristic calculation for the movement cost to each square.

As far as 3D pathfinding, I only have a theory about how you could do it.

If you have a room with an upper level, let's think of an office building with multiple floors, there's only so many ways to get to the next floor. Each floor would have it's own map data for the algorithm to use. So if you're the 1st floor and click somewhere on the 3rd floor, you first need to get to that 3rd floor. Readjust the target destination of the search to a staircase, elevator, or whatever takes to the next level. From that point, do the same for the 2nd floor, find the spot that takes upstairs again. Once on the 3rd floor (the target elevation), then do your typical path search.

3D pathfinding can get complicated pretty quickly. Think of a very open FPS map with multiple levels. Enemy might not take the stairs and just use some jump boots for a direct approach. Or, coming down a level, just fall of the side of a platform and skip the long route to the stairs.

If the character flies and the sky is the map, use the standard A* approach, except your grid is now a cube. More checks for the movement cost as there's now many more directions to check, but the idea and method is essentially the same. On a single level, you have 8 possible squares to choose from (assuming diagonal movement is allowed). If 3D, you have 8 spots on your current level, plus 9 above and 9 below, for a maximum of 26 possible movements.

Anyway, that's just my theory on it. I've never actually tried any of this.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Feb 2018 01:25 Edited at: 15th Feb 2018 01:28
Phaelax,

Have you worked with heap optimization? My code is too slow.

I need to make adjustments, so the CPU does this faster. My CPU load on my computer jumps up 6% if I click on an area I can't move to or its a more complex path(on mobile I am too scared to look lol ). I suspect this is due to the fact I am using a 3 dimensional array, which is causing too many iterations.
Golelorn
8
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 15th Feb 2018 01:45 Edited at: 15th Feb 2018 11:12
Blendman,

Here is my personal code for my doors.

How the doors opens depends on how my character moves in. But its always on the same side of the object to give realism.





Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Feb 2018 15:43
Funny you mention that, I just found this on youtube.

https://www.youtube.com/watch?v=3Dw5d7PlcTM
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-11-26 15:52:03
Your offset time is: 2024-11-26 15:52:03