• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sshaun_10 · Sep 14, 2016 at 12:25 PM · randomspawninfiniterunner

Spawning objects in infinite scroller game

(2D game)

Basic Idea: 2D vertical scrolling plane flying game where the camera follows the plane. There will be lots of items/power-ups scattered randomly throughout the sky, which the player can maneuver the plane to pick up. Some items will have a higher chance to spawn compared to others.

Rather than spawning all the items/power-ups on start, I want to spawn them just outside the camera view as the player moves around the sky at runtime, so as to reduce the number of unnecessary spawning and to allow for an infinite scrolling game.

I'm not sure how to implement the spawning system. All I can think of is to draw invisible boxes around the outside of the camera view, and get the items to only spawn in those boxes as the player moves through the sky. But I can't figure out how to code this. I thought of maybe spawning items at intervals, but then that wouldn't work since the speed of the player would influence how many items spawned in a particular place.

Any ideas or links to other posts that have done things similar to this would be appreciated. I've done a tonne of googling and looking around but I can't find the right info

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

2d Random object placement help? 1 Answer

How to randomly spawn object without spawning the previous object in a row? 0 Answers

Spawning at a random position away from the player 1 Answer

Select from an array based on values 1 Answer

Call a function multiple times 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges