How do I let my Enemy get the Player's Current Position and other variables?

So usually in games Enemies need to know where the player is.

That would require me to in an Enemy Script to get the player’s curernt position constantly.

In java that’s easy.

In the Enemies class you make a
Player p;

and then in the constructor you set p = the player given in the constructor list

and then in update()
theplayerX = p.getPlayerX();


But i know it doesn’t work that way in Unity C#.
How do i do it?

I’m raedy to start my game and that’s one of the basic things i need to do.
Get players variables or Get Objects positions

Like other things i would need to know is:
=Enemy should know if Player is punching him or if player is running away or if players energy level is low

You know things like that

if what you want is player position on c# you can just use this code

using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour {
	
public GameObject player;
public vector3 playerpos; //you need to set the player on the inspector

void update()
{
playerpos = player.position;

}



}