x


Builds differ from editor

I've got a strange issue with unity. I know similar topics have been posted, but I've scoured the forums, answers, and the unity web page for an answer without success.

Everything works properly in the editor... but for some reason I can't get the following code to work in standalone or web:

var spinnerBox = GameObject.FindWithTag("spinnerBox");
spinnerBox.transform.Rotate(0, 10, 0);

This script is applied to a game object with one child, designated "spinnerBox" as its tag. In the editor, it spins, in standalone, it does nothing. I've also tried to use:

var spinnerTrans = transform.Find("<object name>");
spinnerTrans.Rotate(0, 10, 0);

...which has the exact same effect.

I'm very impressed with unity's feature set so far and I'd really love to continue developing with it, but this issue is killing me. Thanks for any help in advance!

-Andrew

more ▼

asked Jan 29 '10 at 05:02 AM

Andrew 1 gravatar image

Andrew 1
11 1 1 2

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

If this is in Update, then you want

spinnerBox.transform.Rotate(0.0, 10.0 * Time.deltaTime, 0.0);

because otherwise it's framerate-dependent. Although it would be better to do

spinnerBox.transform.Rotate(0.0, spinSpeed * Time.deltaTime, 0.0);

and set up the appropriate variable, so you can easily change the speed.

more ▼

answered Jan 29 '10 at 05:38 AM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

Yes, I am aware of this. The issue isn't how the script behaves, it's that it behaves completely differently in different builds (and nothing to do with time).

Jan 29 '10 at 06:04 AM Andrew 1
(comments are locked)
10|3000 characters needed characters left

The main difference that shows up between builds and the editor is the order in which scripts are executed.

I would check very carefully that your awake and start calls are executing in the order you think they should. If indeed it is exactly what you've posted above that isn't working, I don't see anything wrong.

more ▼

answered Jan 29 '10 at 01:38 PM

Horsman gravatar image

Horsman
426 3 6 15

I'm not using any Start() or Awake() functions at all, so that can't be the issue.

I was playing with it today, and discovered that a rotate script I created earlier does work (in both the editor and the web player). So I duplicated the script into a new JS file and applied it to the SAME object (after removing the previous script from it), and it no longer works in the web player (but still works in the engine). Words cannot describe my frustration.

Jan 29 '10 at 10:18 PM Andrew 1

Sounds frustrating indeed, but have you tried adding some debug statements and look in the output log? Do you have the same problem when you make a standalone build instead of a web build?

Jan 30 '10 at 01:42 AM Jaap Kreijkamp

I already posted that I checked the logs and there are no errors. When I build a standalone, there are MORE weird issues, but mostly with timing (and yes, I know how to properly implement time with delta). I'm pretty sure this isn't an improperly implemented script... I reiterate that the SAME script works, but when duplicated into a new .js file and applied to the same object, it doesn't.

Jan 30 '10 at 08:15 PM Andrew 1
(comments are locked)
10|3000 characters needed characters left

Have you looked in the output log when running the game? Except indeed what Eric5h5 says I can't see anything wrong directly but it's hard to say much from two lines of code. If the spinnerbox can't be found, there should have been an exception and this is written in the output log.

If the code is from the update function, it's quite expensive to do a find every update. Better make a global variable and do the find part in the Start function or instead of a find.

more ▼

answered Jan 29 '10 at 06:07 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.5k 20 27 71

Thank you, but again, I'm aware of these things. I'm trying to keep it as simple as possible to be clear where the problem lies.

Either the Find() or the FindWithTag() function (or both) are not functioning in web or standalone releases, but appear to work just fine in the editor. I don't have any errors in my logs. Any idea why this could be?

Jan 29 '10 at 06:18 AM Andrew 1

...and yes, it is happening in Update().

Jan 29 '10 at 06:30 AM Andrew 1
(comments are locked)
10|3000 characters needed characters left

I'm having the exact same problem.

I posted it here: http://forum.unity3d.com/viewtopic.php?t=55264

It seems that my build code will not work with any new .js scripts I create. Once I've copied an pasted in tutorials work fine. Anything I do in the editor also works in the editor (but exclusively in the editor) this is not limited to transformations but to sounds, destroying objects etc.

Does anyone have an answer to what's going on?

more ▼

answered Jun 19 '10 at 12:51 AM

Anthony Paul gravatar image

Anthony Paul
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5273
x2244
x1729
x684

asked: Jan 29 '10 at 05:02 AM

Seen: 1896 times

Last Updated: Jan 29 '10 at 05:02 AM