I defined a GameObject at the beginning of my script
public GameObject “Object”
and wrote
void OnTriggerEnter (Collider col) {
if (col.gameObject == Object) {
SceneManager.LoadScene (2);
Object.Transform.Translate (-720, -220, 220);
}
This is obviously not working, but how do we set the position of the player in the new scene?
Easiest way is to store a vector 3 of the players transform.position in an empty gameobject that is set to dontdestroyonload and prior to your scenemanager.loadscene update the variable with the current player transform and then on the start function of the scene that’s loading or wherever you have it set to instantiate the player have it pass in the vector3 from the dontdestroyonload gameobject.
I’m not at my computer right now but later I can write out the script for you if you need it.
When my Player enters another Scene, I’d like to set the position the Player will begin the scene in, via c#. based on what I currently have written.
I defined my player as a GameObject in the script attached to the collider that takes the player to the next scene. In the case I wrote, public GameObject Object is the Player