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 lil_billy · Nov 17, 2012 at 08:30 PM · cs

JavaScript, lag spammed function call

So here's the deal

I am used JavaScript to make some scripts for my game (which I sort of regret- it was a production speed choice)

Now I have a very performance heavy script that use coroutines every where in it and atm the moment does cause considerable lag.

here's the problem occasionally it will randomly call a function twice-which double spawns a component

are there any uber technical programmers who know the specifics of this bug? does it stem from javascript or unity? is there any way I can make it only callable once?

just to rule out all the obvious mistakes -this script when it runs uses an event to spawn 8 other objects -after testing it multiple times, there is no pattern on which of the child objects have their function double called, its completely random - there is no random behaviors associated with this process - there is only one source that calls the function in question and there simply is no way it can run itself multiple times without causing even greater chaos - the source function is on the original object and the function in question is called on the spawned object -nothing is run in a repetition loop, not even an update function is used

Sorry I can't post the code, It's just so massive, and such a chain of events that it would probably confuse everyone here and take forever to understand it. PS I didnt mean that in any sort of vain or ego blotted way.

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 DioVoid · Dec 09, 2012 at 08:42 PM 0
Share

dude you have been spam$$anonymous$$g ridiculous questions for days now, THERE ARE TUTORIALS!!!!!!!!!. youtube unity for whatever subject, learn some basic program$$anonymous$$g ffs, try javascript "HelloWorld", but no one is going to answer a flurry of (sorry to say) stupid questions. Everyone here was a unity noob at one point and we all recognize that but you got to put forward a $$anonymous$$imum amount of effort here. Hell the scripting reference has example scripts that do 80% of what you ask.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Eric5h5 · Nov 17, 2012 at 09:17 PM

Functions are not ever randomly called twice just by themselves for no reason; it's something you're doing in your code. It sounds like what you have is difficult to debug, but I'm afraid that's what you'll have to do.

Comment
Add comment · Show 3 · 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 lil_billy · Nov 17, 2012 at 09:24 PM 0
Share

gee thanks captain obvious

I know they arent supposed to be called twice randomly but that is exactly what is happening

my actual question is if a lag and the use of coroutines could be responsible for having double function calls

yes the script is tricky to debug but I am entirely certain that there are no other calls to that function

especially because the double call doesnt always happen yet the conditions that enter that process are always the same except for the lag ingame. Like I said there are no random or changing variables used in this process.

it happens more frequently when the lag is worse

avatar image Eric5h5 · Nov 17, 2012 at 09:49 PM 1
Share

Your question is "does the bug stem from Javascript or Unity", the answer is neither. It's stem$$anonymous$$g from your own code, captain oblivious.

avatar image lil_billy · Nov 19, 2012 at 02:54 PM 0
Share

its really not, i can understand why you might think it is but just before the function call is an instantiation so if I were calling it twice I would see a double spawn but I dont

avatar image
0

Answer by lil_billy · Dec 11, 2012 at 04:53 PM

Right so I love all the trolls that have been posting here. Honestly I knew that this subject would invite the obvious answers because it is well a common stupid mistake. However I didnt think that I would get purely crap for answers.

Anyways I will post my current results on this problem

Thanks to more intelligent external sources: I have found out that the root of the problem comes from instantiating within a coroutine and is compounded by mutating that new object within the same routine. So the problem comes from coroutine.

I havent yet figured out a surefire way to resolve this issue. im guessing the only thing to do is to put your generator outside in a non coroutine function

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

11 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

Related Questions

Converting function variable to CS 1 Answer

Unity crashed and corrupted my .cs file,Electricity went down and corupted a .cs file 1 Answer

broadcasting error for targetting script 3 Answers

IpointerClick Interface Error 0 Answers

Enemy AI C# 0 Answers


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