Hello, I want to change sprite depend on angle. But It’s angle is float and sprite list is Integer.
Just cast it.
int myInt = (int)myFloat;
Note that you loose any decimal this way.
@vistriter in your case ,
spriteRenderer.sprite = mySprites[(float)mySprites.Count * angle/360];
No. No, that’s not it. You’re casting it to a float. That’s the opposite of what’s correct.
int index = (int) mySprites.Count * angle / 360f;
1 Like
Take note, the angle is not in degrees, but radians.You need to convert it to degrees before doing the cast.
@Baste oops , seems like I told the opposite, my bad ![]()
