Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by joshuadhayes · Jan 23, 2016 at 01:31 AM · prefabspawnprojectilesavingexit

Game not working when I save, exit out of unity, then come back in.

alt text

So I've attached my code in screenshots.

Pretty simple code. The obtaining of GameObjects through "FindGameObjectWithTag" in the start method is done just to get some empty game objects that are located in the location that I want certain projectiles to spawn at.

The booleans are true when I want them to be. I ran a debug.log of them and they check out.

The problem is that when I initially open up unity, this script won't be working. So I remove the script from the game object it's assigned to in the hierarchy, attach the script again, reassign all the public game objects with some prefabs, and voila, the script works how I want it to. I'll then save the scene and all the scripts, exit out of unity, open it back up, and it stops working.

For the life of me I can't figure out how to fix this, and it's quite annoying to go through the process of fixing it in the way I described above every time I want to work on the game.

Any help will be appreciated.

screenshot-16.png (194.1 kB)
screenshot-17.png (141.0 kB)
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 maccabbe · Jan 23, 2016 at 03:37 AM 0
Share

Are you saving the scene AND the project? Ctrl-s only save changes to the scene and changes to stuff like prefabs requires you to actually do file => save project.

1 Reply

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

Answer by Bunny83 · Jan 23, 2016 at 03:45 AM

"this script won't be working" is't a helpful description of the problem. You said you checked with Debug.Logs. What have you actually checked? If Unity enters one of the if statements and calls the instantiate method it should create that instance.

Removing and readding the script might indicate a race condition between two of your scripts. So the order in which they are executed might be relevant. This script alone certainly isn't the problem. This script relies on Player.alive and shootDelay.canShoot. Those are most likely controlled by other scripts. If those scripts also react to Key down / up events of the same keys it depends on which script actually runs first.

We don't know how your other scripts look like. You have to debug them since you should know how they work. You might want to check your logic and maybe manually set the execution order of your scripts to ensure a certain order.

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 joshuadhayes · Jan 23, 2016 at 01:43 PM 0
Share

Sorry, I will try to be more descriptive next time I ask a question.

But you were right. I had a code in another script that was turning shootDelay.canShoot false before the prefab could instantiate.

Thanks for your help!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to Use Object Pooling? Is my Script Wrong? 0 Answers

Unity Crashes When Spawning Prefab 2 Answers

Ingame prefab saving and manipulation 0 Answers

Projectile not launching from correct place - rotation or positioning issue? 0 Answers

Make a object spawn 1 Answer


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