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 AlbiScando · Jul 12, 2017 at 10:53 AM · simulationstoppinguma

Why my editor stops working during a simulation in play mode?

Hi everyone! I'm trying to run a simulation with a hundred of agents generated with random features with UMA. But even though i call the function to create them inside the Start() and make them move in the Update(), they start moving while they're still generating. To avoid this, i made this if statement inside the Update() function if ( frame_numb > avatar_numb) { ...code for moving... } frame_numb++; .My idea was to prevent them from moving before all of them were created, assuming that every frame generates an avatar. But using the Debug.Log() and running the simulation i noticed that some avatars take two frames to be created. Also, when the editor gets around 70-80 avatars in play mode, it stops working. Could it be my laptop is not strong enough to support this simulation? Because the code seems ok.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by crisis-sheep · Jul 12, 2017 at 11:15 AM

Hmm, if I'm not mistaken (and forgive me if I am) you're assuming Start() is called once per frame? It is only called once (like a constructor). If it's creating other GameObjects their Update() methods will start to fire as soon as they're created because they'll be on a different thread (if I'm not mistaken – caveat: I'm no expert).

You might want to keep your agents deactivated until they're all done generating? Then you wouldn't have to do any ugly checks during Update().

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 Waka-Takaki · Jul 12, 2017 at 11:41 AM

@crisis-sheep has the right idea I think with not enabling the objects until all are completely ready. In your create object method finish it with something like:

avatarObject.enabled = false;

Then add at the beginning of update a check to see if the full quantity are ready then loop through them enabling them all.

I'm on my phone atm so can't be more specific really

Comment
Add comment · Show 6 · 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 crisis-sheep · Jul 12, 2017 at 11:54 AM 0
Share

Or you could enable them all at the end of Start()

avatar image Waka-Takaki · Jul 12, 2017 at 12:00 PM 0
Share

True true. As long as he finishes building them in Start

avatar image crisis-sheep Waka-Takaki · Jul 12, 2017 at 12:23 PM 0
Share

That's a point. @AlbiScando I'd recommend reading the manual entry on execution order to make sure you don't get into null-reference territory.

avatar image AlbiScando crisis-sheep · Jul 12, 2017 at 12:51 PM 0
Share

Thanks a lot, the manual helped! I missed a detail from the manual "Start: Start is called before the first frame update only if the script instance is enabled...... Naturally, this cannot be enforced when an object is instantiated during gameplay." I think the problem is here, as in my scene at first i only have the environment where the action takes place; my avatars are created right during gameplay. So, as i understood, everything i do to them in the Start() will be done when as soon as the first frame begins and not before.

Show more comments

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

70 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 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 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 there any cloth cutting simulation or script in Unity 1 Answer

Particle Simulation 2 Answers

Physics based multiplayer simulation game 0 Answers

Not Able to Convert 2D trajectory(right Side) into 3dTrajectory(forward Direction)... 1 Answer

Application.Load() issue 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