#Having trouble coding enemies for multiplayer game

5 messages · Page 1 of 1 (latest)

copper oxide
#

Hello! I’m trying to learn to create a 2D RPG multiplayer game. I try to learn godot by creating a single player game first. However, there’s not much tutorial on creating enemies for multiplayer. The enemy I try to create include three properties:

  1. Can chase player if any player is in certain range.
  2. Attack the player if the player is even closer
  3. Otherwise just roaming around

I’ve try to turn my single player tutorial game by myself to a multiplayer game. The tutorial I follow is:
https://dev.to/christinec_dev/lets-learn-godot-4-by-making-an-rpg-part-11-spawning-enemy-ai-50e
https://dev.to/christinec_dev/lets-learn-godot-4-by-making-an-rpg-part-13-enemy-dropping-loot-on-death-2e18
https://dev.to/christinec_dev/lets-learn-godot-4-by-making-an-rpg-part-14-enemy-shooting-dealing-damage-2540

I set a Game Manager to store my player information and also set a group for my players

What I’ve try is to calculate the closest player and check the distance to decide how the enemy will perform, but it’s doesn’t work for all the enemies I spawned, it’s only work for 1 enemy.

Thank you for understanding my questions and I’m looking forward for any enemy structure suggestions or any tutorial I can follow. Also I’ll provide more information if needed

DEV Community

Imagine how much work it would be to manually add 50+ enemies to our scene. This not only looks...

DEV Community

We can finally shoot and kill our enemy, but we can do one better. I want us to upgrade our enemy’s...

DEV Community

It won’t be fair if the player is the only entity in our game that can deal damage. That would make...

tiny beacon
#

Its going to be difficult for anyone to suggest anything, if nobody can see your code. Rather than posting tutorials for other people to wade through and guess, show what you have done.

#

"What I’ve try is to calculate the closest player and check the distance to decide how the enemy will perform, but it’s doesn’t work for all the enemies I spawned, it’s only work for 1 enemy." This for example might be a place to start.

copper oxide
#

Thank you for your suggestion! I’ll provide my code😄

copper oxide
#

Here is how I spawn my enemies, I'm also struggling to synchronize there position, I've only try add a multiplayer synchronizer node as a child of enemy node and synchronize there position but it's doesn't work.