- Home /
The question is answered, right answer was accepted
Prefab GameObject is rendering(?) at a different scale per scene
I feel like I'm missing something simple but I can't figure out what's going on here. I have a deer sprite that I turned into a prefab and have on both the Main menu and the staging scenes I'm currently using for testing. For some reason a 1 scale on the main menu is roughly half the height of my player while a 1 scale in the staging scene is quite a bit bigger (amplified by the script I have running that slightly randomizes instances sizes, images below). I thought it might be the different camera settings I had as I'm not entirely familiar with how Cinemachine works, but after disabling it for testing I couldn't see any changes. I just want the deer prefab to be the same size in each individual scene. I hope it's something that I just need another set of eyes to take a look at. Image(s):
Basic 1 to 1 scale difference between scenes:
The worst it can be when they're scaled by the script:
As you can see, it goes from being roughly the same height as the player to almost doubling his height (with antlers included...). No idea what's causing it, but any assistance is greatly appreciated!
P.S. please excuse the in progress art and shoddy photoshop stitch of the issue images. Had to get as much info into them as possible so you could see what I was talking about. Also, I know it's not the player sprite because I actually measured it between scenes. Definitely something going on with the deer prefab.
Answer by Lord_Grumpledorf · Nov 30, 2018 at 04:07 PM
Alrighty, looks like I managed to figure it out. Don't have the slightest idea what caused it, and the solution isn't exactly the optimal choice, but here it is. Just delete all instances of the prefab, and then the prefab itself and remake it... Doesn't feel great having to redo the same work, but this was a relatively small prefab so it wasn't too bad. Looks like I'm a relatively singular case here, as I did a lot of googling prior to asking this question and couldn't find anyone else encountering this issue. I'll be closing the question out now, thanks to R4y-GM for assisting!
Answer by R4y-GM · Nov 28, 2018 at 07:04 PM
hmmm there are any scripts or animators?
There is a script and animator, but they are identical on both instances and the script doesn't work on a multiplicative scale (so it doesn't take current 1x scale * 2 or something, it just sets scale manually to 1.5 or whatever it generates). I'll just post the size bit here.
else if (type == "Deer") transform.localScale = new Vector2(rand = Random.Range(1.2f, 1.5f), rand);
what is doing your transform.localScale can you post a part of your code?
why you are doing a random value between 1.2 and 1.5? transform.localScale = new Vector2(rand = Random.Range(1.2f, 1.5f), rand);
if you want your scale to 1 transform.localScale = new Vector3(1f, 1f, 0f) put this on your start void or update void
Follow this Question
Related Questions
Skew a sprite at runtime while preserving the pixel shape? 1 Answer
2D sprite wavering 0 Answers
Difference between Sprite and Default texture types? 0 Answers
Normalized UV from batched sprite sheet 0 Answers