How to set a Transform variable with code (C#)

I’m trying to make a game where enemy will be generated at a random place when someone starts it, and therefore I need to set a Transform variable to a cube called “Player”. Is it possible and how would I do it?

public Transform myTransform;

any object in unity has Transform Component;
thats the one that show the positions and rotaition or scale of an object;

more question u can ask me in my gmail :

A simple approach would be to use the GameObject.Find syntax.

Using that approach you could then easily determine the transform of the cube.

Perhaps you could even study the Transform.Find syntax.

There are many examples, probably thousands of examples, available that a simple google search will serve to help eliminate your problem. Most of those search results will lead back to this forum.

Hello! It actually quite simple -

public/private Transform name

About the random place, there are many ways to do that. The first thing that comes to my mind it using Random.insideUnitSphere

I hope that helps. I wish you a great day :))