Im creating a 2d shooter. I wrote a script that says that if my gun's eulerangle is less than 270, but greater than 90, it will change its sprite.
Script:
var Gun : GameObject;
var newSprite : Sprite;
function Update () {
if(Gun.transform.rotation.eulerAngles.z < 270 && Gun.transform.rotation.eulerAngles.z >90) {
GetComponent(SpriteRenderer).sprite = newSprite;
}
}
I put this script on player's body, gun ,head and legs. But when it switches sprites, sprites appear on diffrent positions. I make sprites on photoshop. Maybe the problem is that I create random picture sizes when I mirror my sprites? Please help.
↧