- Home /
Need help in instantiating at desired position.
I am trying to instantiate a bullet in a 2D game .But the bullet spawns exactly at the center of my player(a 2D ufo). I have tried adding an vector 3 to it but the bullet doesn't use the worldSpace then I guess . It spawns at desired location but when I rotate it spawns exactly there .
Instantiate(bulletPrefab, Player.transform.position ,
, Player.transform.rotation);
Answer by SirPaddow · Aug 08, 2019 at 08:49 PM
I think the best way to do it is to attach a child "BulletSpawn" to your player gameobject, with nothing in it except the transform. Then, instead of keeping a reference to your player in the spawner, keep a reference to the "BulletSpawn" transform, and use this position in the Instantiate function.
Your answer
Follow this Question
Related Questions
Trying to instantiate prefabs to a parent object with C# script. 1 Answer
instantiate prefabs y+1 from last instintiated prefab 1 Answer
Distribute terrain in zones 3 Answers
How i can make a cube maze 0 Answers
How to manipulate a variable of a prefab script (instantiated) while the game is runnning . 1 Answer