Hi.
I have this weird thing when I am changing from menu scene into playscene. Sometimes if I hhit esc to get into menu bunch of times my player position will get on 0,0,0 coordinates which is default. I have this script on player gameobject:
void Awake()
{
Vector3 spawnPoint = new Vector3(5 * 16, 60, 5 * 16);
transform.position = spawnPoint;
}
First I thought it is something weird with my static values but I changed it to hard coordinates as seen above. In like every few attempts it will spawn at 0,0,0 and it drives me mad.
Any suggestions why it might be?
Do you have any other scripts or code within this script which modify the player’s position?
Do you have a character controller on the player?
I went through all scripts and no this was the only place which changed the hard transform of player object. I solved it by removing the player from the scene and saved it as prefab and then instantiate it with given coordinates.But did I do something bad? Why having player object directly in scene and changing his transform act this weird I even debuged it and for awake and start it clearly had those coordinates.
PS: I am using character component exactly the same from brackeys with some tuning to gravity and jump height.