x


[Closed] Stop strange scaling at runtime

I have an enemy (the same one as in previous questions of mine) where I have its scale set to 1.5. The parts of this enemy (children) all have a scale of 1. When I run the game, the enemy disappears...because its scale changes to 10 (which I did not script). To fix this, I thought I would change the scale every frame back to 1.5 by setting all of the transform.localScale values to 1.5. The enemy still scaled up to 10, but did reset to 1.5. The body of the enemy turned out fine, but all of the other parts of the model ended up scaling down to .1. I tried the same tactics on the parts of the enemy to scale them back to 1, but the parts that scaled down are then in the wrong position (shorter arms because they are buried within the body, eyes that moved to behind the body, etc.). I'm desperately trying to get this enemy (which worked at one time) to function. Is there anyone who has any idea of why the enemy is scaling up to 10 or how to fix it? There are no animations (yet) for this enemy.

more ▼

asked Jun 15 '12 at 10:38 PM

You! gravatar image

You!
447 8 14 16

Are there other scripts involved messing with the model? Have you tried reimporting the model? Does the same happen if you just drag the model/prefab into the scene directly? If not, is its scale correct? Also, if nothing else helps try experimenting/changing the ScaleFactor in the import settings.

Jun 15 '12 at 10:43 PM Wolfram

There are no other scripts that change the scale of the model, or any of the other models. The original model (the one that I edited in Unity to get to where I am now) had it's parts jumbled around (I don't know why) but I have rearranged the parts to their correct positions. When I create a prefab of this and re-import it, I do not receive any weird changes, with the scale being correct. It just scales strangely when I press play, and re-scales when my localScale changes take effect.

I also found out that I misspelled "localScale" in some of my coding (CAPITAL LETTERS!!!) and I changed it. I'm updating my question to reflect these changes.

Jun 15 '12 at 11:00 PM You!

#pragma strict is your friend!

Jun 15 '12 at 11:01 PM whydoidoit

...#pragma strict is being too friendly!... It came up with no errors the the scripts that would have any affect on the transform of the enemy.

Jun 15 '12 at 11:13 PM You!

But it would have found your localScale problem I think...

Jun 15 '12 at 11:15 PM whydoidoit
(comments are locked)
10|3000 characters needed characters left

The question has been closed Jun 16 '12 at 07:20 AM by You! for the following reason:

The question is answered, right answer was accepted


1 answer: sort newest

I know you said there are no animations yet, but I'd double-check that you don't have any Animation components at all, since even a "non-animated" default animation might be able to change the scale.

If that's not it, it's probably just some script changing the localScale without your knowledge. You should be able to figure out what it is using process of elimination (start removing scripts from all the components in the scene until it starts working again, and if it still happens with no scripts then check your editor scripts). Alternatively, maybe the undocumented OnTransformChanged callback still works and you could use it to get a call stack of when the scale changes.

more ▼

answered Jun 15 '12 at 11:31 PM

jspease gravatar image

jspease
569 1 3 6

The animation component thing definitely did it. Thanks for the tremendous help that completely fixed that and another problem that I had previously!!!!!!!!!!!!!!!!!!

Thanks again :D .

Jun 16 '12 at 07:19 AM You!
(comments are locked)
10|3000 characters needed characters left

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:

x655
x388
x31

asked: Jun 15 '12 at 10:38 PM

Seen: 468 times

Last Updated: Jun 16 '12 at 07:19 AM