How to make a simple AI in 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gelgavish

Hi

I’m new to Godot and I want to make my first FPS game with this engine. The FPS part itself is already done. I got stuck making an enemy, the enemy I want to have is very simple, he just follows the player in the 3D space.

Can someone help me implement this?

Thanks! :slight_smile:

:bust_in_silhouette: Reply From: Dlean Jeans

Simplest pseudo-code, I guess:

func _physics_process(delta):
  var to_player = translation.direction_to(player.translation)
  move_and_slide(to_player * speed)

How would I add gravity to the AI character?

Wodsobe Dobe | 2020-01-15 21:57

Just like you added gravity to your player

Dinoking | 2020-09-22 04:47

This isn’t working.

toivocat | 2022-06-01 17:05