You have 5 reels. Each reel has 100 objects/“Symbols” on it. Each reel must move the symbols down. When the symbols move past location y, then move that symbol back up to the top.
I’m interesting in seeing how others might do this because it seems that moving hundreds of objects at once causes slow performance on the iphone.
I would probably have a go at offsetting the texture using Material.SetTextureOffset. Then the reel objects never have to move ! And the texture would wrap around automatically ! - this is assuming of course that your symbols are images on a texture map applied to the reel object.
Danny,
I’ve used that method before for our armor system in Word Warrior™, but am unsure if that would work in this case. First, I could have from 12 to 15 DIFFERENT symbols. Those wouldn’t all fit on one sprite sheet. Secondly, the symbols are in a specific order on each reel. So on reel one for instance, I might have (out of the 12-15 different symbols) 50 symbols. They would be required to show in this order (if they symbols are numbered): 1,3,12,5,6,3,3,3,2,11,6,8…etc. That order cannot change. So scrolling through the offset of a sprite sheet wouldn’t work. Also, jumping to specific texture offsets to obtain the right order also wouldn’t work, because then the reel wouldn’t have the appearance of spinning. Am I not understanding what you are saying?
Since the order of the symbols is set in stone, you could lay out your sprite(texture) sheets, one for each wheel in the order you need them, from top to bottom. Offset the UV’s vertically, and when they stop, you query where your UV’s are on each wheel, to find out what symbol you are on.
So I’ve got my reels moving and it looks good, but it won’t seem to maintain precise movements/locations. Everything stays pretty “close” (meaning the distance between symbols) but not exact. What I do is have each symbol initialized with speed and locations, then I move them in their own update methods like so:
currentReelSpeed = reelSpeed * Time.deltaTime;
transform.Translate(Vector3.down * currentReelSpeed);
//If we have reach the bottom move up to the top
if (transform.position.y <= reelBottomEndPosition.y)
transform.position = reelTopStartPosition;
In essence what i’m trying to do is have the symbol move back up to the top position after it reaches the bottom position. But like I said, this is too imprecise. Any ideas on a better way to move these?
All of these symbols are children of a game object, and moving the game object would keep the symbols moving uniformly, the only problem is I would be unsure how (if moving the main game object) to get each symbol to move to the top of the stack.
( for 3D only ) as an alternative to melmonkeys post you could divide your 3D reel into 50 ‘faces’ then apply the UVs of each face to the right part of the texture. Dead easy to do in Maya with Copy UVs and Paste Uvs.
Also this way you can just have the individual symbol only once on your texture atlas !
edit Please note in this case you would have to rotate the actual object - offsetting the texture would not work edit
Thats a nice way to do it dannyflint, unfortunately it is a 2D game. There has to be a way to move many objects simultaneously at the same speed without having slight inaccuracies.
With regards to it being a 2D game, you can still use a 3d object and rotate it. Your game world is still 3d, not 2d, so it isn’t an issue.
I was going to suggest the 3d wheel as an alternative, because it will allow you to create a nice square texture for your icons, and be able to use compression on the device.
Animate everything using iTween, it will make your life so much easier.
I was working on a slot machine game (which I have mothballed for now). I was trying to use iTween but there were some issues at the time with rotations > 360 deg. Have to get back to that.
What I found was that some times you have to (re)postiton the reel to exact coord’s after a rotate due to floating point drift. if not reels start to get out of alignment and it doesn’t look so good.
btw I was using 3D objects for the reels and items as I wanted it to look 3D. On the iPhone the performance wasn’t bad if things were batched but the inital spin was always a little jerky as the grahics were getting cached.
Also you have a lot more items on your reels that I did. I think I was using 24 per reel.
The initial spin hitches would need to be dealt with by getting all the graphics cached before your game starts. A crafty way to do this is during your first loading screen, instantiate and immediately destroy a bunch of cubes with the game materials and textures applied. This will put everything into memory, so you should be good to go.
As to the floating point drift…I have a couple ideas to try out before I write up the big ugly post
I was about to post my own thread asking this question, so glad I searched first. I too am wondering about how to do this. We don’t have the limitation that Mark does - the reel doesn’t have to have an order - the ending pattern is all that matters. In Flash, the “reel” was 5 movieclips - 3 in the visible window, and one above and below. Bottom one is only used if an EaseIn animation was used to start the spin. As in Mark’s system, once the bottom symbol moved to it’s lowest Y position, it would be moved to the top of the screen. Each movieclip had a frame for each symbol, so it was a simple to set the final symbol pattern.
I was also trying the same thing. When GameObject reaches last positon it moves to the top. But then the gameobjects are not alligned properly. SO if you guys have a solution to solve this please let me know.
if you could tell me how did u spin the reels, it will be very helpfull for me doing my project, i am also working on a five reel, spinning the reel has became the biggest challenge for me, i tried to do using rendered.material.maintexture offset but it is not giving appropriate spin, could you tell me how to spin the reels, thanks
i am newbie to unity, i am trying to make a slot game, above you said dividing reel into 50 faces, how to do it, can you tell me in brief, which will be very helpful for my project