0 votes

Hello, I've been following an action RPG series by HeartBeast and I went up to making the enemies but I want them to go around collisions and still be able to follow the player. The best and simplest solution so far that I could find was this article from abitawake:
https://abitawake.com/news/articles/enemy-ai-chasing-a-player-without-navigation2d-or-a-star-pathfinding

I went through this and I was really confused, I skipped the getting started step since I got no idea about where the enemy variable came from so instead of this:

I'm using this:

So I went to the next step, I got this error here:

I also created the Scent.tscn which has a Node2D named Scent and a Timer, the Node2D has a script attached with the same code as in the article:

This is where I am currently stuck at, I would really appreciate some help, thanks.

Godot version v3.2.3 Stable
in Engine by (21 points)

1 Answer

0 votes
Best answer

Have a look a bit with the link you posted here, seems like that tutorial uploader doesn't include the declaration of the "player" variable in the Player.gd.
Here, try this:

func add_scent():
  var scent      = scent_scene.instance()
  scent.player   = self # Change to this
  scent.position = position # Also this
by (117 points)
selected by
Making enemies avoid collisions without the A* algorithm
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.