I’m having a problem with itween’s rotateBy function.
I have three reels on a slot machine, and a variable for each reel (x, y + z). Z will always be > y, and y will always be > x.
Variables x, y, z set how much to rotate reel 1, 2 and 3 by, respectively.
Instead of rotating about their centers, they seem to rotate about some other weird axis instead, as you can see in the pics below:
I’ve got the math right for how much to rotate each reel by, but obviously something I’ve either done, or missed is causing the reels to rotate around something else. Any help would be really appreciated, or if there’s a better way to do this I’d love to know.
Also, about every other time I run it, it crashes Unity iPhone.
//now we start spinning
var re1 = GameObject.FindWithTag("reel1");
var re2 = GameObject.FindWithTag("reel2");
var re3 = GameObject.FindWithTag("reel3");
while(z>0){
if(z>5){
iTween.rotateBy(re3,{"x":5, "delay":0.1});
z -=5;
}
else{
iTween.rotateBy(re3,{"x":z, "delay":0.1});
z = 0;
}
}
while(y>0){
if(y>5){
iTween.rotateBy(re2,{"x":5, "delay":0.1});
y -=5;
}
else{
iTween.rotateBy(re2,{"x":y, "delay":0.1});
y = 0;
}
}
while(x>0){
if(x>5){
iTween.rotateBy(re1,{"x":5, "delay":0.1});
x -=5;
}
else{
iTween.rotateBy(re1,{"x":x, "delay":0.1});
x = 0;
}
}