0 votes

Hi, I know this can be hard but I need help with AI, the thing is that I want the Second object"enemy" follow the first one then the second is visible into screen, Can anybody give me some ideas? The enemy doesnt have to avoid obstacles so I think that is a little easier but I dont know where should I begin.... The game is 2d

in Engine by (91 points)

1 Answer

0 votes

Look up the GameFromScratch tutorial on Navigation, or the demo on NavPoly in the demo folder. I think that's what you want for path finding. Also for LOS, you may want to look into the RayCast node or other collision nodes for that. If you are using tiles (TileMap), here's a cool demo for adding Navigation into tiles. Link to demo Sorry for the lack of detail, I'm in Ludum Dare so i'm stressed and busy :( :)

by (846 points)

Thanks but what iam looking fot is a way to make a enemy follow the character in a 2d platformer something that helps to change the direction of the enemy when it see the character... Something like sight range

Oh... well for side scrolls I usually see game devs using 2 ray cast nodes, one going the direction the player is facing (left or right), and one going 45 degrees down from where the first one is. Not 100% how that works, but I'm guessing it somehow detects the edges of platforms. But yeah, that's all I got, good luck.

Yes, something like that is whht i was looking for but, i am stuck about how to do it if you have some ideas I would like your help

Hi I'm late for the party but it didn't look like you got stuff resolved. Stumbled on this looking for some obstacle avoiding tips funny enough...
But here is what I've done (simple but works for now), for a node following another node, on a 2d tilemap:
func whatevermovefollow():

if myposition.distanceto(mytargetspos) > whencloseenoughforchasetostart
if mytargetpos.y > mypos.y:
my
pos.y += my_movementspeed (if grid, then grid size or number of grids * size)
elif y. < y
elif x > x
elif x < x

getnode(me).moveto(mynewpos)

Hope it helps someone stumbling upon this :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.