Set different start positions for my player
Hi! I'm new here in unity and coding. I have been searching for this, but nothing really helps me. Here is the situation. I'm working in a scene transition where you can exit a scene by two different points to the same second scene (I mean, you can go outside via door or window). Now, I want to set different locations depending if you took the window option or the door option.
I tried declaring in the player script:
public Vector2 _startPosition;
And in the SceneSwitcher script:
public Player _startPosition;
public void Awake()
{
//TODO: Cambiar la posición inicial de Player según salga por puerta o ventana
_startPosition = transform.position;
}
Now I have in the player inspector, a new spot where I can define x, and y, but it obviously doesn't work.
Thanks!!
Answer by rubendelpinoperales · Dec 19, 2020 at 09:52 PM
After more attempts, I have something in the script that looks... coherent?
In the SceneSwitcher script
public Player _player;
public Vector2 _startPositionV;
public Vector2 _startPositionP;
public void Awake()
{
_startPositionP = _player.GetComponent<Rigidbody2D().transform.position;
}
Now I have in the SceneSwitcher inspector the two vector2 parameters for Windows and Door, and the option to attach the player. But, still nor working.
Your answer
![](https://koobas.hobune.stream/wayback/20220613021914im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Input.location.isEnabledByUser is always false, while developing on Win7 1 Answer
LocationServices on iOS provides much higher measurements than on Android 0 Answers
How to get the position of different objects using the same script? 0 Answers
mainmenuscript keeps crashing the game 0 Answers
Loading a scene with script loads multiple copies of another scene, the crashes Unity 0 Answers