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 /
avatar image
-2
Question by Shockwave317 · Nov 07, 2014 at 03:06 PM · 2dgameobjectsstatictop-down

Is this how you enemy instance.

So, I am trying to make a 2d top down game but I am having a problem with gameobjects all deleting etc... Also there are different enemies but how do I make them seperate entities and only kill one at a time.

So I guess my main question is for static is it for individual gameobject only or is private?

Comment
Add comment · Show 1
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 FairGamesProductions · Nov 08, 2014 at 03:10 AM 0
Share

If you want this question answered, you HAVE to rewrite it with better English and better description of your problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiwasi · Nov 08, 2014 at 04:09 AM

Best advice for beginners is don't use static. The main reason is pretty evident from your problem. There are other hidden evils of static variables.

There is no task in Unity that can't be done without static variables. Once you understand how to get a project complete without using any static variables, then you can consider how and where to implement them.

Comment
Add comment · 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
0

Answer by kburkhart84 · Nov 08, 2014 at 04:39 AM

Your problem is likely stemming from the use of "static" which can indeed be evil. As a quick description, it kind of forces there to be only one of something. For example, if you have a static variable in a class, and you have multiple instances of that class, there would only be one of that static variable, and in any instance in which you modify that variable it will be modified in all of the instances.

What you are looking for are prefabs. You can have a scene open, create your enemy, bullet, whatever, and then store it in a prefab. You can then take that prefab and duplicate it easily in all of your different scenes via the editor, and you can also call Instantiate() to create duplicates at run-time, useful for shooting bullets from your guns for example as the bullet would likely be a prefab.

Another very good benefit of prefabs is that as long as you don't break the connection(won't happen unless you force it to break), anytime you change the prefab(or an instance when you send the changes back to the prefab) will get sent to all of the copies of the prefab automatically.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Generating Game Objects on random positions (2D) 1 Answer

where to trigger which collision event? 1 Answer

How I make my enemy face the player or flip towards player (top-down game)? 0 Answers

GameObject with SpriteRenderer either on top of everything or not showing 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