Enemies following a Player

Hi,

Currently I have a cube as a player and 3 spheres as enemies. With this script, I make them follow my Player:

GameObject player = GameObject.FindGameObjectWithTag ("Player");
this.transform.LookAt (player.transform);
this.transform.position += transform.forward * moveSpeed * Time.deltaTime;

My Cube is a normal cube, nothing special to it. I just made his box collider bigger. The spheres are like that:

GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = spawmPoint.transform.position;
sphere.AddComponent<Rigidbody>();
sphere.AddComponent ("EnemyAI");
sphere.tag = "Enemy";

So there are several things I want to do:

  1. Enemy should follow Player - this works quite okay
  2. The enemeis should not merge, they willl because they are pointing on the same direction. So I added a rigidbody. Is there a better way to accomplish that?
  3. The enemy should stop when they collide with the player and should start attack or something. Currently, I’m using a flag set in OnCollisionEnter(); doesn’t really work but also didn’t try it hard, think I’ll figure this out.
  4. The player and the enemy should not influence them self in a physical manner. So, if I run against the sphere, the sphere should not move, like it would in a normal physical environment. So, how can I do that?

I did read a lot but somehow can’t come up with the right idea. The important questions are 2 and 4.

Thanks for any help

2: I would use a character controller, the rigid body is for more physics realistic scenarios where you need to have your object receiving forces and torque.
3 and 4: Don’t move the enemy always. Use conditionals and check when the enemy is colliding with the player and only move the enemy when this is false.