Search Unity

How would YOU make a slot machine (Moving reels)

Discussion in 'iOS and tvOS' started by spentak, Dec 2, 2010.

  1. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    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.

    Thanks,
    Mark
     
  2. SquishyPixels-Glimmer

    SquishyPixels-Glimmer

    Joined:
    Apr 30, 2010
    Posts:
    125
    do you want 2D or 3D?
     
    Tomal2015 likes this.
  3. dannyflint

    dannyflint

    Joined:
    Mar 12, 2010
    Posts:
    28
    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.
     
    Last edited: Dec 2, 2010
  4. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
    I would go with the texture method Danny outlined above.

    Otherwise, I would look at using iTween for the animation.
     
  5. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    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?
     
  6. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
    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.
     
  7. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    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:

    Code (csharp):
    1.  
    2. currentReelSpeed = reelSpeed * Time.deltaTime;
    3. transform.Translate(Vector3.down * currentReelSpeed);
    4.                
    5. //If we have reach the bottom move up to the top
    6. if (transform.position.y <= reelBottomEndPosition.y)
    7.     transform.position = reelTopStartPosition;
    8.  
    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.
     
  8. dannyflint

    dannyflint

    Joined:
    Mar 12, 2010
    Posts:
    28
    ( 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*
     
    Last edited: Dec 3, 2010
    bijukchheaashish92 likes this.
  9. spentak

    spentak

    Joined:
    Feb 11, 2010
    Posts:
    246
    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.
     
  10. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
    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.
     
  11. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,048
    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.
     
    Last edited: Dec 5, 2010
  12. melmonkey

    melmonkey

    Joined:
    Mar 31, 2009
    Posts:
    373
    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 :)
     
  13. kragsdale

    kragsdale

    Joined:
    Jan 18, 2011
    Posts:
    1
    Hi everyone,

    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.

    Kevin
     
  14. united4life

    united4life

    Joined:
    Oct 5, 2012
    Posts:
    2
    Hi,

    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.
     
  15. smartiesid

    smartiesid

    Joined:
    May 2, 2013
    Posts:
    4
    Hi,

    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
     
  16. smartiesid

    smartiesid

    Joined:
    May 2, 2013
    Posts:
    4
    hi,

    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
     
  17. Tomal2015

    Tomal2015

    Joined:
    Nov 18, 2015
    Posts:
    2
    Can you make a slot game for me in playcanvas.com? I'll pay you $400 for that. The game engine is similar to unity.
     
  18. sathish10

    sathish10

    Joined:
    May 9, 2017
    Posts:
    1
    how to create animation for reel objects in slot game?, and i am using NGUI plugins
     
  19. carldevelopsforcoffee

    carldevelopsforcoffee

    Joined:
    Sep 20, 2017
    Posts:
    19
    My setup:
    - slot item images are on a sprite atlas (for easy replacement)
    - item data (id, sprite, payout)
    - reel data (int array, corresponding to item data ids)
    - reel game object contains slot item objects (around 10 objects)
    - 10 objects are used to display the slot items (even a 100 slot item reel)

    movement: ( a slider system. )
    - start by setting up a random target item on your reel
    - create a new list of slider items (data of items that will be seen in
    the spinning/sliding)
    - setup slider item positions
    - move slider item positions downward
    - slider items in the visible range gets a game object and the object's sprite uses the item data mapped to the slider item(hope u guys can imagine it)

    this system has been used in several of my slots apps. i can do freelance consultations (carljoven@gmail.com)
     
    ysftulek likes this.