Skip to main content
added 242 characters in body
Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

Your code spawns the obstacles at transform.position which refers to the position of the game object this script is attached to.

So you just have to move the game object with this script to the location where you want the objects to spawn.

I am not sure what exactly you mean with "go through that spawn as the sprite goes up". But if it means that you want the spawn location to somehow change throughout the game, then you would either have to add some code to move the position of this game object or you would have to stop using transform.position as the instantiation location and instead create a new Vector3 with the spawn coordinates you want.

Your code spawns the obstacles at transform.position which refers to the position of the game object this script is attached to.

So you just have to move the game object with this script to the location where you want the objects to spawn.

Your code spawns the obstacles at transform.position which refers to the position of the game object this script is attached to.

So you just have to move the game object with this script to the location where you want the objects to spawn.

I am not sure what exactly you mean with "go through that spawn as the sprite goes up". But if it means that you want the spawn location to somehow change throughout the game, then you would either have to add some code to move the position of this game object or you would have to stop using transform.position as the instantiation location and instead create a new Vector3 with the spawn coordinates you want.

Source Link
Philipp
  • 123.2k
  • 28
  • 264
  • 345

Your code spawns the obstacles at transform.position which refers to the position of the game object this script is attached to.

So you just have to move the game object with this script to the location where you want the objects to spawn.