0 votes

Hey guys, I am working on a project in godot and I need an experienced developer to help me out. I am trying to make mobs for my game their goal is to follow the player once the player is close enough (I got this part working) but, they also need to wonder around the map when the player is not close enough, i.e they need a.i. I do not know how to do this and would really appreciate anyones assistance. Thank you in advance

in Engine by (23 points)

Your post is a bit sparse on details. 2D or 3D? What node type are you using for your enemy? What type of game are you making? Sidescroller? TopDown? Something else? How exactly do you want the AI to behave? How often shall their change direction? Are they allowed to roam the level freely or restricted to a certain area?

1: It is 2D
2: Enemy Node type is KinematicBody2D
3: The gameplay all happens in one scene
4: I want the AI to move around on its own and when the player is close enough, I want it to chases the player, but if the player escapes the AI should continue moving around on its own
5: It can change direction at random times and a random amount of times
6: They are allow to roam the level freely as they wish

thank for replying by the way :)

1 Answer

0 votes

You could use a randi_range to randomize the locations the ai chooses.

by (75 points)

Yeah, that could work, but I need my mobs to be moving around on their own, not choosing one location and remaining and that random location

They wouldn't have to, you could set it so when they reach that location they wait for a random amount of time and then choose another location.

Yes you totally are right, the lightbulb went on in my head, I will give it a try and let you all know, thanks for your input!!!

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 Frequently asked questions and 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 [email protected] with your username.