Discuss Scratch

Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Hey, so I've looked around and I haven't found any project with a free-form enemy AI pathfinding script.
If your wondering what I will be using this for. A game I'm making would be great with pathfinding.

It's a GMOD Nextbot game, and it would be much better with pathfinding.
It's a scrolling game as well and I would like the pathfinding to be as similar to GMOD as possible.

Hopefully you can do this!
It needs to update 24/7.

Cheers,
(game link in my signature)

Last edited by Loganmcc04 (Nov. 17, 2022 12:38:35)

Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

bump
zappgame_version3
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

I'm gonna follow this because I need one too lol
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

bump
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

bump
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

bump
YetAnotherDeveloper
Scratcher
13 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

If your game is simple enough, this will work: https://scratch.mit.edu/projects/741621953/
If any part of it interferes with the code, try following the pathfinding tutorial by @griffpatch on Youtube

For scrolling games, you'd need a complex grid list to store directions to each goal from each position, similar to how Griffpatch's part 2 tutorial works, but more complex.

Last edited by YetAnotherDeveloper (Dec. 15, 2022 17:03:25)

Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

YetAnotherDeveloper wrote:

If your game is simple enough, this will work: https://scratch.mit.edu/projects/741621953/
If any part of it interferes with the code, try following the pathfinding tutorial by @griffpatch on Youtube

For scrolling games, you'd need a complex grid list to store directions to each goal from each position, similar to how Griffpatch's part 2 tutorial works, but more complex.
I'll follow part 2, and see how it works. My game is a 2D scrolling game. All I need is

nextbot near wall = avoid it and still get to the player
huboojoe
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Loganmcc04 wrote:

YetAnotherDeveloper wrote:

If your game is simple enough, this will work: https://scratch.mit.edu/projects/741621953/
If any part of it interferes with the code, try following the pathfinding tutorial by @griffpatch on Youtube

For scrolling games, you'd need a complex grid list to store directions to each goal from each position, similar to how Griffpatch's part 2 tutorial works, but more complex.
I'll follow part 2, and see how it works. My game is a 2D scrolling game. All I need is

nextbot near wall = avoid it and still get to the player
i think the next bot should just not point to the walls, or change it's movement depending on the distance
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

huboojoe wrote:

Loganmcc04 wrote:

YetAnotherDeveloper wrote:

If your game is simple enough, this will work: https://scratch.mit.edu/projects/741621953/
If any part of it interferes with the code, try following the pathfinding tutorial by @griffpatch on Youtube

For scrolling games, you'd need a complex grid list to store directions to each goal from each position, similar to how Griffpatch's part 2 tutorial works, but more complex.
I'll follow part 2, and see how it works. My game is a 2D scrolling game. All I need is

nextbot near wall = avoid it and still get to the player
i think the next bot should just not point to the walls, or change it's movement depending on the distance
It points at the player, and distance wouldn't work. As the distance is calculated from the sprites origin.
the-one76
Scratcher
4 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

All you have to do is: point towards player move however many steps.
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

the-one76 wrote:

All you have to do is: point towards player move however many steps.
I don't think you understand what I'm trying to make here.

Last edited by Loganmcc04 (Dec. 23, 2022 12:55:29)

Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

bump
Kaungy_2009
Scratcher
44 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Are you trying to add buildings to your next bot game? Im trying to make buildings for an update on my nextbot game but im struggling with a collision system.

Im trying to use nodes for the nextbots to follow, its much easier than path findings but I think it would take more time.
Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Kaungy_2009 wrote:

Are you trying to add buildings to your next bot game? Im trying to make buildings for an update on my nextbot game but im struggling with a collision system.

Im trying to use nodes for the nextbots to follow, its much easier than path findings but I think it would take more time.
Nodes could be useful, but putting them in the level would take ages, and I have multiple maps.
Mixm_Productions
Scratcher
18 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

If you're trying to set the bot's code to follow the player, then this might work:
This is for your enemy sprite
when green flag clicked
set rotation style [left-right v]
repeat until <touching [playerBlock v]>
point towards [playerBlock v]
move (5) steps
if <touching [playerBlock v] > then
change (lives v) by (-1)
end
end
Kaungy_2009
Scratcher
44 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Mixm_Productions wrote:

If you're trying to set the bot's code to follow the player, then this might work:
This is for your enemy sprite
when green flag clicked
set rotation style [left-right v]
repeat until <touching [playerBlock v]>
point towards [playerBlock v]
move (5) steps
if <touching [playerBlock v] > then
change (lives v) by (-1)
end
end
Hes trying to make a better nextbot ai he already use that code.
NintendoCoder22
Scratcher
3 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

Heyo, I need a avid coder who can implement controls for a player2 in a 2d shooter/platformer, into a AI opponent that's capable of doing what the player can do. (Run, jump, shoot etc.) https://scratch.mit.edu/projects/782150245/
thebig_coolguy567
Scratcher
3 posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

i need a way for the AI to walk around normally instead of bumping into walls.
Game:
https://scratch.mit.edu/projects/974224713/
and they are not enemies

Last edited by thebig_coolguy567 (Feb. 29, 2024 16:23:49)

Loganmcc04
Scratcher
100+ posts

⭐ How do I make a free-form enemy AI pathfinding script? ⭐

thebig_coolguy567 wrote:

i need a way for the AI to walk around normally instead of bumping into walls.
Game:
https://scratch.mit.edu/projects/974224713/
and they are not enemies
I'm no longer on scratch, and this is necroposting. Please don't revive dead threads.

Powered by DjangoBB