- Home /
How do i make objects spawn from a custom location?
How do i make a script that allows me to drag an object into a variable slot in the project view and spawn it at a location i set? Please help me its driving me mad
Answer by govi627 · Jan 31, 2013 at 03:26 AM
I think you are looking for instantiate? You start by placing an empty game object anywhere in your scene.
Here is a code that makes a slot for your prefab:
var thePrefab : GameObject;
function Start () { var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation); }
Attach this script to your empty game object(which should be placed where you want your prefab to appear). Then you will be able to drag whatever prefab you want onto that slot. Hit play and it should work.
Joe
Answer by smillyfaces · Feb 29, 2020 at 04:44 AM
depends, if your making a network game use an empty game object with the component network start position then attach that to another game object with the component network manager and network Hud manager, then slide in your desired player pre fab with the component network identity, then add a camera to the scene to act as your Hud camera and it should work. just move the spawn point anywhere in the scene and your done, but if your doing single player just do what govi said.
I ment slide the player predfab into the spot that says missing player prefab
Your answer
Follow this Question
Related Questions
Destroy Istantiated objects after some time (different for each instance) 1 Answer
Question Local Translation PRoblem 2 Answers
move particle direction with player 1 Answer
repeat object spawn 3 Answers
AI Help FPS 0 Answers