Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by MarvinH · Mar 27, 2013 at 01:35 PM · designarcadeshmup

What is the best way to handle Off Screen Enemies in a SHMUP?

Hello,

I'm working on fixed position vertical scroller. The player's ship can't move off screen, rather the level comes to him. The best example of this is Art in Game's Air Attack HD. I'm also looking at a lot of classic arcade shooters like 1943. My question, How do those games handle off screen enemies?

In my current game build, I create triggers that are attached to a scrolling background. When the player goes through the trigger, an enemy spawns at an off screen trigger point. this kind of works, but the enemies sometimes appear in the middle of the screen, not really ideal. As it stands, I have to create a ton of triggers. Is there a better solution?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by jmatthews · Mar 27, 2013 at 01:48 PM

I assume your visible screen clip is defined by a rect of some sort. If you're using an orthographic camera it will be defined by the orthographic size and then adjusted by your screen resolution. You want to hone in on that rect and use the far right bound and spawn mobs to the right of that.

If your scrolling speed is constant you can spawn waves of mobs based on time but that may complicate your level lay out. You can cut your number of triggers by having a single trigger begin a series of spawns(a wave) and then assign that wave to one trigger, and a different wave to the next trigger.

For offscreen spawning the easiest way I've found is to simply define a 2d bounding box that you're going to spawn mobs into and place it above(or in your case to the right) your viewport and high enough where the largest spawned mob is still not visible even if you spawn it at the nearest part of your bounding box.

My approach is code-centric and is simply a function of time. My scroll speed is constant so I simply spawn waves of mobs based on time and after a few playthroughs you get a feel for what spawn speed does to your level of difficulty. The benefit of this approach is that when you implement difficulty levels you can crank up the number of mobs easily as well as their strength.

Comment
Add comment · Show 3 · Share
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
avatar image MarvinH · Mar 28, 2013 at 10:45 AM 0
Share

Thanks! That definitely seems like a good alternative. Are you spawing enemies off of a timer on some type of game manager object? How do you keep track of all the mobs? ie 30 seconds instatiatie mob 1, 60 secs instantiate mob 2. Etc. Thanks for your help.

avatar image jmatthews · Mar 28, 2013 at 06:02 PM 0
Share

You're going to have to play with it and find something you like. This part of the design is the type of stuff that translates to the look and feel of the game and ends up defining what it is exactly that you've created.

I have a $$anonymous$$ob$$anonymous$$anager class that exposes a public gameobject spot for each mob type. Through the editor I link all my mobs(prefabs) on that script. Each mob shares a "mob" interface so I can keep them in a single list. This serves as a repository for all my mobs and all of the functions that act on them.

The mob responds to requests from an outside component(my Level$$anonymous$$anager)and serves up waves of mobs.

Internally(in the $$anonymous$$ob$$anonymous$$anager) I have two lists. One list holds instances of mobs that are deactivated so I'm not thrashing my garbage collector, and the other list is active mobs on screen at the moment. **edit - You could implement this as a single list pretty easily and may be just as good.

I have functions that run on my active mobs giving them a time slice for AI, movement, etc. and I cull these mobs against my screen rect to deactivate them when they've moved out of the play area or been destroyed.

$$anonymous$$y level manager is where I store stuff like difficulty and number of mobs in the level, and variables like "pace", "statboost" etc, that lets you dial up the challenge as need be.

That's a bunch to soak in but the fun part is you can do it a thousand other ways and still be right. Do what makes sense for you.

avatar image MarvinH · Mar 29, 2013 at 01:44 PM 0
Share

Thanks! You've given me a ton to think about. I will need to do some research into how to script this. Thanks again.

avatar image
0

Answer by whydoidoit · Mar 27, 2013 at 02:25 PM

Well you would often do those based on a timer rather than triggers and you can work out what that timer would be based on the position of the object and the speed of the scrolling so that it is enabled just off screen.

Comment
Add comment · Show 1 · Share
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
avatar image whydoidoit · Mar 27, 2013 at 04:11 PM 0
Share

You know - I really wouldn't move the background - just use a script fix the camera above the player and move it forwards (but not left and right) :)

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.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you attach enemies to a moving background? 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Scripts/code sitting outside of individual scenes 2 Answers

Starting the Project 1 Answer

PingPong game ball physic problem 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges