© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
12 replies
TearsRfuel

why is this while loop infinite?

this is crashing unity:
(complete beginner btw literally just started messing around with code 2 days ago)

If i click on an object with a cube or sphere tag, generate some random values, destroy the object I clicked on, genereate a new random spawn position using the random values. WHILE the new spawn position is colliding with an existing object, generate a randomSpawnPosNew, and set randonspawnPos equal to that, once the random spawn position is not colliding with any other objects, instantiate the object that we clicked on.
tst.PNG
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Breaking an infinite while loop
C#CC# / help
3y ago
Infinite loop
C#CC# / help
2y ago
Winforms infinite-loop
C#CC# / help
2y ago
while-loop
C#CC# / help
4y ago