Enemy AI - Getting an enemy to go towards player c#

I’ve been working on a game for a little while, but I’m very new to Unity, or should I say java.

As title says I’m trying to write a script that makes an enemy go towards the location of player and on collison take away a life.

		void FindAIinput ()
		{
			inputMovement = objPlayer.transform.position - transform.position;
			inputRotation = inputMovement;
		}

However, If I put this code in the same code as the player it will work fine, but I wish for the enemy to have a seperate script as they’ll be many enemies in this game and I feel that could be easier.

void FindAIinput ()
{
inputMovement = objPlayer.transform.position - transform.position;
inputRotation = inputMovement;
}

Ok, your code here makes NO sense. You say you’re using “Java” a.k.a Javascript but this function is declared in C# syntax.

You’re creating a vector between the position of the gameObject the script is attached to, and the position of whatever objPlayer (hopefully the player GameObject). Then you are trying to assign this new vector to something called ‘inputRotation’. Rotations in Unity are stored as Quaternions, not vectors, so that won’t work at all.

I recommend digging into some tutorials so you can learn how this all works. If I gave you the answer here you’d simply need another fish tomorrow, and the day after and so on… learn to fish and you can feed yourself.