0 votes

Hello there!

Since I know how to move my player in my 2d top-down space game, I would like to create some NPC too. But I don't actually know how to do it.

  1. NPC movement
    I think that using a kinematicBody2D should be fine, but how to make it move in a random direction with its speed and after some time, calculate new direction and also turn the NPC by its turn speed?

  2. NPC field of view
    Also, I've read the docs about the dot product. But I actually didn't get the logic. I mean, when a player enters the NPC radar range (Area2D should be good for that), how to also turn the NPC to face the player?

I searched on google for AI and NPC tutorials for Godot but I haven't found the answer.

Please, I am still new to programming so further explanation for everything would be welcomed.

Thank you in advance! :-)

in Engine by (61 points)

Please log in or register to answer this question.

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.