Search Unity

Select Starting Point from Menu

Discussion in 'Scripting' started by camnea, Jan 16, 2021.

  1. camnea

    camnea

    Joined:
    Jan 16, 2021
    Posts:
    1
    Hi everyone,
    I looked up for tutorials and articles about it but seems like it's not a common topic, so apologies if it seems a dumb request.

    I created a scene in Unity which the user can explore and interatct with. I read about script to select between different scenes in the application, but couldn't find one where I have ONE scene (I took a random axo on internet), and different starting point I decided for the user to use as start point for the exploration:



    Is there a way to "select" them from a starting menu? Or as a menu/option inside of the scene? Any reference on this?

    Thanks to everyone!
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,911
    You could do something simple like:
    • For each possible starting/spawn point, create a GameObject there with a new script you create called "SpawnPoint". Give that script something like a "SpawnNumber" variable, and se them all to different things in the inspector. Then, from your main menu, you let the player choose a spawn number. Transfer the chosen value across scripts using a DontDestroyOnLoad GameObject.
    • When your exploration scene loads, read the chosen value and spawn or reposition the player to the chosen spawn point.
     
    mikeohc likes this.
  3. mikeohc

    mikeohc

    Joined:
    Jul 1, 2020
    Posts:
    215
    Adding to the suggestion above, you can make an Array of starting points that transform player position to the gameobject transform.

    e.g. Menu Select Screen -> Location0Button -> int startLocation = startPoint[0] -> transform player position to startPoint position.