- Home /
Need help with AI in multiplayer
I'm working on a coop horror game. I attached this script to an enemy, so it will follow the player:
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist = 5;
function Start ()
{
}
function Update ()
{
transform.LookAt(Player);
transform.position += transform.forward*MoveSpeed*Time.deltaTime;
}
Now the problem is: when I start the game and connect to the server, the enemy won't follow the player. Instead the enemy moves to the player's spawn. Does anyone know how to fix this?
(Sorry if my English isn't that good, I'm Dutch)
Do you correctly assign the player transform to be the actual player?
Answer by Drshk7 · Jun 30, 2013 at 06:19 PM
Hello :D Here are the things you can try:
Try to look at and move towards the player by identifying the player by tag.
(Someone else already said this but) Make sure that the player variable has the player instead of the player spawn assigned.
It could be a multiplayer glitch. Do you Network.Instatiate the players or are they there in the scene? I suggest trying to Network.Instantiating the players instead of putting them in the scene.
Also, I would make a range system so that when one player gets closer to AI than the other, it follows that player. Since you only set it to follow player, it will only follow one player.
Hope this helps :D
(I am a beginner-intermediate at multiplayer in Unity3D)
Your answer
Follow this Question
Related Questions
How to run a script to only 1 player in a multiplayer fps 1 Answer
Damage script is screwed up...? what to do? 1 Answer
Erro in MultiPlayer 0 Answers
AI Script attached to Enemy and is Rotating around player 0 Answers
Problem with the enemy 0 Answers