Assigning Transform

Hello, Unity scrub here
Just a question on this code here. Basically I’m trying to get the x and y position of the player in a script that controls a different object. I can’t figure out how to do this. This is the code that I have so far:

public class OrbController : MonoBehaviour {
	
	public float orbSpeed = 1.0f;
	Transform player;
	Vector2 playerPosition;
	

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if(player){
			float distX = Mathf.Abs (player.position.x - transform.position.x);
			float distY = Mathf.Abs (player.position.y - transform.position.y);
				if(distX < 5 || distY < 5){
					Vector2 amountToMoveOrb = new Vector2(Input.GetAxisRaw ("Mouse X") * orbSpeed, Input.GetAxisRaw ("Mouse Y") * orbSpeed);
					transform.Translate(amountToMoveOrb);
			}
		}
		
	
	}
}

Basically, how do I assign the player Transform so I can get the position in x and y?

Declare player public so that it shows up in the inspector.

public Transform player;

You will then be able to make the assignment by dragging the player object into this slot in the OrbController’s inspector.

Awesome, thanks for the quick reply