I want to parent the game object the script is attached to to the main camera. I have this so far:
// Get the transform of the camera
var camera = Camera.main.transform;
// make it a child of the current object
camera.parent = transform;
// place it behind the current object
camera.localPosition = -Vector3.forward * 5;
I know this script does the complete opposite but I don't know what to do from here to parent the game object that the script is attached to to the main camera. Do you know?
↧