- Home /
Question by
Carter_Knighted · Oct 29, 2021 at 11:51 PM ·
tweening
Do Tween Slot Machine Reel movement
[code=CSharp] IEnumerator Spin() { bool canMove = false;
transform.DOLocalMoveY(machine.positionToReset, machine.startSpeed).SetEase(machine.startEase).OnComplete(() => {
Vector3 newPos = transform.localPosition;
newPos.y = machine.resetPosition;
transform.localPosition = newPos;
canMove = true;
});
while (!canMove) yield return null;
canMove = false;
for (int i = 0; i < reelSpins; i++)
{
transform.DOLocalMoveY(machine.positionToReset, machine.speed).SetEase(machine.reelEase).OnComplete(() =>
{
Vector3 newPos = transform.localPosition;
newPos.y = machine.resetPosition;
transform.localPosition = newPos;
canMove = true;
});
while (!canMove) yield return null;
canMove = false;
}
transform.DOLocalMoveY(machine.stopPosition, machine.stopSpeed).SetEase(machine.stopEase).OnComplete(() =>
{
spinFinished = true;
paylineSet = false;
});
}[/code]
Hey Guys! I'm working on a slot machine and am trying to have the reels smoothly transition. I'm curious what you think of my approach and if you have any recommendations on how I could improve the tween. The code attached is on each of my reel objects that holds the reel icons. Thanks!
Comment