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
0
Question by Marcurion · Dec 11, 2011 at 03:26 PM · prefabsdestroyed

Prefabs wont disapear

Hi, i tried a doodlejump clone but the items that are beneath the player dont get destroyed i tried something like that on the itemprefab:

 public gameObject Character;
 void Update()
 {
     if (Character.transform.position.y -15f> transform.position.y)
     {
         Destroy(gameObject);
     }
 }

but it does not work...

Greetings Marcurion

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

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by funkyllama · Dec 11, 2011 at 03:58 PM

I don't mean to point out the obvious but is the difference greater than 15? But one thing I notice that is wrong with your script is public gameObject Character should be public GameObject Character. Note the uppercase G

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 Marcurion · Dec 11, 2011 at 06:58 PM 0
Share

Hi, thanks for your answer. Yes diffrence is greater than 15 and in my script GameObject is uppercase.

Greetings $$anonymous$$arcurion

avatar image
0

Answer by Marcurion · Dec 11, 2011 at 07:01 PM

Thanks for your answer. Yes difference is greater than 15 and in my script GameObject Character has uppercase G

Greetings Marcurion

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 TheCodeMonkey · Dec 11, 2011 at 08:01 PM

Just using the code you gave in your question I have an object destroying when it is 15 below whatever target I give it. The problem does not appear to be in your script as it functions fine, perhaps you are linking your objects to the wrong "character" object, or they never actually get 15 below the player to be destroyed. If your objects are prefabs that are being instantiated be sure to check that they are properly linking to the character.

Try changing the distance at which they destroy to a very small number for testing purposes, whatever the problem is it is not with your script. as long as gameObject is an uppercase G that is.

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 funkyllama · Dec 11, 2011 at 09:23 PM 0
Share

Yep, that'll be it. Come on $$anonymous$$arcurion, admit it, you forgot to link your character.. We've all done it :) :). Are you getting any NULL References in your console when you run it, if so then that'll be the reason :)

avatar image
0

Answer by Marcurion · Dec 12, 2011 at 08:44 AM

No sorry, i would be happy if that were the problem - all prefabs are properly linked. Maybe it matters that i let the prefabs spawn by another prefab...

MFG Marcurion

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 Marcurion · Dec 12, 2011 at 08:58 AM

Ok i found something: The problem occurs if i put the box with the script attached into the empty prefab, the link to the character gets cut, and it refuses drag and drop a new GameObject, but i can select an GameObject over the small circle menue, however the script does not work once it is in the prefab

Greetings Marcurion

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

Scripts of Objects which I've deleted through the editor still exist and are run 0 Answers

Count Prefabs on builded .apk 0 Answers

Multiplayer different player prefab 0 Answers

PrefabUtility does not exist? 1 Answer

how can i make prefabs keep there inspector varibles 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