Hello, I'm completely new to Godot (but I'm experienced programmer). I wanted to do simple shooter with enemies spawned to different paths at runtime. I created spawner node with this method in it:

func spawn_enemy(path: Path2D):	
	var i = enemy.instance()
	#get PathFollow2d and add enemy to it:
	var pathfollow = PathFollow2D.new() 
	pathfollow.add_child(i)
	path.add_child(pathfollow)

Now - 1. How to move this enemy along the pathFollow2d? 2. Should the movement code go to enemy script, spawner script, path2d script or somewhere else? 3. Do I have to add _process method to spawner for rendering purposes?

Thanks!

@Testeria said: Hello, I'm completely new to Godot (but I'm experienced programmer).

Welcome to the forums @Testeria!

  1. How to move this enemy along the pathFollow2d?

I'm not 100% positive myself, as I have not used the PathFollow2D node really that much, but I would recommend looking at some tutorials. Here's a few I found:

  1. Should the movement code go to enemy script, spawner script, path2d script or somewhere else?

I'd recommend putting it in the enemy script if you can, as that way you can have different enemies move in different ways later if needed.

  1. Do I have to add _process method to spawner for rendering purposes?

Nope! You do not need to add _process for rendering, you just need a node that has some visuals to render. You only need _process or _physics_process if you have code you want to execute every frame (_process) or every physics frame (_physics_process).

2 years later