Home > Back-end >  prefab gameobject is becoming skewed when I am modifying transform.up
prefab gameobject is becoming skewed when I am modifying transform.up

Time:12-29

in my 2d unity game, i am randomly instantiating zombies that I want to face their mouth towards the center where there is it's target because the bullets come out of their mouth which need to face the center. the zombie is a prefab and I have this code on it: transform.up = -(kids.transform.position - transform.position); it is pretty much working and there are no errors except, randomly, sometimes it becomes really skewed and squished in weird ways. here is a picture of what it looks like when it is skewed: enter image description here

how can I make it not get skewed? thanks.

CodePudding user response:

Probably you scaled it or one of its parent Transforms uniformly. Possible solution: create a parent which is unscaled and do the rotations there. Maybe have a script to follow some other transform, like settings its position in an update, if need be. A child Transform of the unscaled Transform, which you rotate, can then still be ununiformly scaled.

  • Related