0
\$\begingroup\$

I turned my player into a prefab for a endless runner game but how would i instatiate it so that the player is in the scene when the game starts without it currertly being on a seprate platform that the player then ends up jumping from to get onto the road

\$\endgroup\$
6
  • \$\begingroup\$ I'm sorry, but I read this question several times and have still no idea what the actual problem is. Can you please rewrite it as a series of complete, grammatically correct sentences with punctuation? Also keep in mind that we can not see your project or your code. "Platform" and "road" are abstract concepts that only exist in your game. If you want others to understand what you mean, you have to describe them using the technical terms of the things you represent them with. \$\endgroup\$
    – Philipp
    Commented Apr 14, 2023 at 8:59
  • \$\begingroup\$ @Philipp im dyslexic so dont tell me to write like im in school i can not do that .. and secondaly i dont have any code to show .. its also pretty simple all i want to know is how to INSTANSIATE my player and dont tell me to rewrite it \$\endgroup\$
    – charlie
    Commented Apr 14, 2023 at 9:06
  • \$\begingroup\$ I am sorry that you are dyslexic, but that does not change the fact that I can simply not understand what you write. I would like to help you, but I can not help you when you can not describe the problem in a way that I can understand it. \$\endgroup\$
    – Philipp
    Commented Apr 14, 2023 at 9:08
  • \$\begingroup\$ @Philipp ALL I WANT TO KNOW IS HOW DO I INSTANIATE MY PLAYER READ THE TITLE \$\endgroup\$
    – charlie
    Commented Apr 14, 2023 at 9:10
  • \$\begingroup\$ @Philipp sorry didnt mean in caps \$\endgroup\$
    – charlie
    Commented Apr 14, 2023 at 9:10

1 Answer 1

0
\$\begingroup\$

You would just drag the prefab into the editor. See also: https://stackoverflow.com/questions/72361621/how-to-get-a-reference-to-a-prefab-asset-in-unity

Instantiation at runtime seems also given in the docs here: https://docs.unity3d.com/Manual/InstantiatingPrefabs.html

public class InstantiationExample : MonoBehaviour 
{
    // Reference to the Prefab. Drag a Prefab into this field in the Inspector.
    public GameObject myPrefab;

    // This script will simply instantiate the Prefab when the game starts.
    void Start()
    {
        // Instantiate at position (0, 0, 0) and zero rotation.
        Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);
    }
}
\$\endgroup\$
4
  • \$\begingroup\$ it is in the editor but doesnt appear on the end;ess runner bit only the platform o had created temporailry \$\endgroup\$
    – charlie
    Commented Apr 14, 2023 at 9:57
  • \$\begingroup\$ This would work for the initial placement, but since it is for an endless runner, OP will have the same problem when coins, power ups, barricades or respawn has to be handled. The answer could be improved if you explain as well how to instantiate at runtime via code (or link to one of the many answers that handle that already) \$\endgroup\$
    – Zibelas
    Commented Apr 14, 2023 at 9:59
  • \$\begingroup\$ @charlie the green tick means, the answer solved your problem and no further answers are really expected (since people see it as solved). \$\endgroup\$
    – Zibelas
    Commented Apr 14, 2023 at 10:00
  • \$\begingroup\$ @charlie , have linked to the docs, hope that helps \$\endgroup\$
    – mleu
    Commented Apr 14, 2023 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .