Ok, I have been searching around and found a few ideas but none seem to work.
What I am doing in I have the player on the main scene enter a building, the building scene loads and I need the player to start at the location near the door. When the player exits the room, I need the player to start back where he was before he entered the room.
public var pos : Vector3;
var default : Vector3;
var player : Transform; //Place the player transform here in the inspector
function Start () {
DontDestroyOnLoad(transform.gameObject);
}
function OnLevelWasLoaded () {
if(Application.loadedLevelName = "FancyNameOfMainScene"){
if (position = null){
player.position = default;
}
else {
player.position = pos;
}
}
}
“pos” is the variable which contains the position which the player will load to, “default” contains the default loading position of the character, and “player” is the character. “pos” is public so that another script (like the one which you use to load the room) can access it and change it to whatever is required or desired by using ScriptName.pos
“DontDestroyOnLoad” ensures that this script and the object it is attached to will still exist when the main scene is loaded again, making sure that the script comes to good use.
I made the change here: //PlayerColl.cs
void OpenDoor1()
{
GameObject.Find(“OnScreenMSG”).guiText.text = “Press O to open door.”;
if(Input.GetKeyDown(“o”))
{
Assets/Scripts/PlayerColl.cs(61,95): error CS0246: The type or namespace name `PlayerPos’ could not be found. Are you missing a using directive or an assembly reference?
Assets/Scripts/PlayerColl.cs(63,42): error CS0664: Literal of type double cannot be implicitly converted to type float'. Add suffix f’ to create a literal of this type
Assets/Scripts/PlayerColl.cs(64,42): error CS0664: Literal of type double cannot be implicitly converted to type float'. Add suffix f’ to create a literal of this type
Assets/Scripts/PlayerColl.cs(65,42): error CS0664: Literal of type double cannot be implicitly converted to type float'. Add suffix f’ to create a literal of this type
Thanks for your help with this, I am still very new with Unity