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 Sarthak123 · Nov 03, 2014 at 01:59 PM · prefab-instanceinfinite terrainintantiate

Intantiated objects deleting themselves automatically.

I have a script which instantiates object(land) like to create a infinite land in one direction, here is the script.

 var land : GameObject;
 
 function Start () {
 
 }
 
 function Update () {
 
 }
 
 function OnTriggerEnter(other : Collider)
 {
     if(other.tag == "Player")
     {
         var landins = Instantiate(land, Vector3(0,0, transform.position.z + 10), Quaternion.identity);
         landins.name = "Land";
     }
 }
 
 function OnTriggerExit(other : Collider)
 {
     if(other.tag == "Player")
     {
         Destroy(gameObject);
     }
 }


It works perfectly awesome, but after some time(Infact after exact time or to say at a exact location) this script stops working, i.e. it stops instantiating objects and automatically deletes obejects it has instantiated except the last one.

I cant figure the problem itself.

Note - My Scene is completely empty it only has a land block and player.

EDIT - i somehow figured out what's happening at the last block(at z co-ordiante 450) instead of instantiating next block at 460 it is instantiating the block at 450 itself, which is causing this problem. any ideas, why?

Conclusion I Reached - First when i start from z-cordinate 0 than i am able to reach 450 before if stops spawning the next at more distance, second, if i start at 450, i am able to reach 2300 Z-axis but it stops at 2300 z-axis as at it stopped at 450.

Comment
Add comment · Show 4
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 troien · Nov 03, 2014 at 02:38 PM 0
Share

Are you incrementing the speed of the player over time? $$anonymous$$aybe you player goes that fast that it basically rushes over your block in less than one frame, Preventing both OnTriggerEnter and OnTriggerExit from being called.

avatar image sysameca · Nov 03, 2014 at 02:50 PM 0
Share

To me the code seems legit enough to continue building blocks each 10 units on the Z axis. However a lot of times strange things happen in specific situations and sometimes for other people is not easy enough to spot a particular bug. $$anonymous$$aybe you can provide the demo project as it is so it would be easier for people to see exactly what is happening and try to help you.

avatar image Sarthak123 · Nov 03, 2014 at 03:24 PM 0
Share

ah actually i think the player's speed or physics was messing it. i just imported first person controller and set it's speed to 1000, and yet it was working perfectly fine, while i tried putting the speed to 500 in my controller and the script(intantiater) stopped at the very first moment, so what i did was removed the capsule collider from my controller and set the initial speed to zero while incrementing the speed, and it now works fine, atleast i tried a few times, and it reached upto 15,000 without a problem. so i think either the initial speed was messing or the capsule collider...

avatar image sysameca · Nov 03, 2014 at 03:34 PM 0
Share

Try to scale your cubes and terrain overall to smaller units, it will be much more easier for you to work while program$$anonymous$$g.

1 Reply

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

Answer by Sarthak123 · Nov 03, 2014 at 04:05 PM

hmm, i think its due to the initial speed, if i start the player with the speed 0, and then increment it like a car, then everything's work fine, however if i preset the speed, to something greater than 5 or 10, then it causes a bug at 450 co-ordiante and nearby per increase/decrease in speed, so i think initial speed was the problem, i will check again after adding some more entities... to check if it's still the problem or not.

thanks for suggesting the hints by the way

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

29 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 avatar image avatar image avatar image avatar image avatar image 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

Is it possible to put a world space UI onto an instantiated object? 1 Answer

How can I infinitely generate tiles, and randomly generate prefabs on top of them with a script?,How can I infinitely generate tiles with randomized prefabs on them? 0 Answers

Using Resources.load with a variable 1 Answer

Change one intance, change all the prefab - Not found the correct answer in other threads 1 Answer

Making multiple instances of a prefab,Instantiating multiple instances of a prefab 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