Unsure about how references are made to this object's transform and Unity in general.
Hi, I know referencing is a very basic topic, but I am very unfamiliar with Unity's workflow... I've had experience in Java, so OOP is nothing new, but there are several questions I have about some code I ran into, which I've written here:
private Camera cam;
private Transform myTransform;
void Awake() {
cam = Camera.main;
myTransform = transform;
}
How can the myTransform variable be assigned to simply "transform"? What exactly is that referencing? I assume it is "this" object's transform, but this syntax seems a little strange because it's not explicit.
In contrast, the cam variable is assigned to Camera.main, which is another weird reference for me. Whose camera is that? What if I had multiple cameras? Is there a main camera always, and how is that decided?
Please correct me if I'm wrong, but from my limited exposure, I understand that unity is a bunch of objects that consist of components that allow the objects to interact with the current scene. If objects want to change/interact with each other, the acting object needs a script that has public variables that I explicitly tell to reference by dragging in the object being acted on.