playMaker

Author Topic: Rotate a cube  (Read 4672 times)

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #15 on: October 14, 2013, 05:44:17 AM »
Yeah I had thought about that, but only had about an hour to put this together.

It could be resolved several ways.. maybe by counting the spawn points, dividing by how many different tile types/cube types you have being placed, then creating that number of each type in sequence to make sure there are the same number of each. You would do best to setup a board that has an evenly dividable number based on how many cubes you have, to make things simple.

There are other ways as well. We're basically making a world-space array system, so it may be better to just move on with Arraymaker after you get the general idea of how it can work from this example.

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #16 on: October 14, 2013, 05:56:39 AM »
I have never used Arraymaker before.

What about to just have two of each cards and you just place them randomly in the PlayAreaSpots?

As it is now, It create a random object of the prefabs and place it in the spot.

So if I have two blue, two green, two yellow, etc. And in the start of the game, in the Start State, I make them appear randomly at the spots, if you know what I mean?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #17 on: October 14, 2013, 06:47:08 AM »
I think if there are a static number of slots, yeah.

I preferred to count the spots, divide them up, then create the game tiles so you can make a play area of any size by placing more spots and not need to change the Game FSM. Better for long-term.

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #18 on: October 14, 2013, 07:45:48 AM »
Are you going to make that when you have time? Sounds so difficult for me. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #19 on: October 14, 2013, 07:56:02 AM »
Give it a whirl, study the example and see what you can accomplish. You'll be stuck forever unless you learn these how these things can be done and apply that knowledge on your own.  :) 3 months ago this would have been impossible for me to do, now its fairly straightforward because I took the time to practice and learn.

If you're still stuck on it after a few days I'll modify it and you can compare the examples.

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #20 on: October 14, 2013, 11:58:54 AM »
Yes, you're right. I will see what I can do. I need to study it. And change things to see what's happening. Thank you for helping. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #21 on: October 14, 2013, 02:15:47 PM »
I'm a little bit stuck with these random thing.
First I tried the easest way. To just have two of each card, and put them at the spot randomly. But the problem was that it could happened that two cards could appear at the same spot.

You don't need to solve it for me. Just give me some ideas I can try. :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #22 on: October 14, 2013, 02:18:47 PM »
Have you changed any other variables?

It counts the children of the PlayArea object, then stores that count and repeats the spawn object loop and each time gets the next child, so technically that shouldn't happen. If that is the problem area you might try putting a Next Frame Event in the loop just in case. Often times it goes too fast (i guess) and weird things happen.

If you went to two object only then you should have just had to change only the create object action to use 2 slots instead of 3. The whole system should have still worked after that.

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #23 on: October 14, 2013, 03:37:13 PM »
I just tried to delete the first states until the state Idle. Just to see if I could make my own random system. So I didn't change any variables.

So I can maybe change something in the FSM so it's only two matching cards on the board at the same time? This was more difficult than I thought. I know how to make one cube random.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #24 on: October 14, 2013, 04:02:26 PM »
Ha! Yeah it's certainly not trivial =)

The approach I took and thought process:

  • Create a "Play Area" Game Object
  • Create the "Spot" game objects that I would make Game Tiles would spawn at.
  • Store the Spots as children of the Play Area
  • Count the children objects of the Play Area, store that count in a variable. This is all of the possible spots that the Game Tiles can spawn, and the number of tiles I will have on the board during play.
  • Use Get Next Child (of PlayArea) and use that as a spawn point for Create Random Game Object and list the available game tiles there.
  • Subtract one from that count since we just spawned a Game Tile
  • Loop this set of actions until....
  • A String Compare action is checking to see if The Count variable has reached zero, meaning we're done filling the game board. If its zero, then go on and move into the next part of the game state

Hope that gets you going =)

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #25 on: October 14, 2013, 04:25:27 PM »
Ok, thanks! I will give it a try tomorrow, Now it's sleeping time . :)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #26 on: October 15, 2013, 12:05:29 PM »
Hi!

Thank you! Now I'm understand what's happening, but I want only two of each color in the PlayArea. Two blue, two red, two yellow, etc. How can I do that?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Rotate a cube
« Reply #27 on: October 15, 2013, 12:33:09 PM »
Are you wanting a smaller board size? Just reduce the number of Spots in the PlayArea, and move them where you want the tiles to be spawned at. You could just move them to a different object or something as well.

It is a little more challenging to maintain an equal number and I'd have to look at it for a while to cook something up, likely the spawning system will have to be changed quite a bit. The computer needs to know how many of each tile to spawn, so that would be the available spawn points divided by the number of tile options.

Then it needs to know where to spawn them, if its in sequence then you can use Get Next Child to store the spawn point, if its random then you need Get Random Child and also have to destroy the Spot you just spawned into so that it doesn't randomly choose it twice on accident.

It also needs to know how many of each tile that it has created, so you can likely use the existing subtraction method, but have a separate integer for each tile type you are spawning.

You can do it though, its just a matter of thinking through it and experimenting =) Figure out what the computer needs to know and find a way to give it that information.

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #28 on: October 15, 2013, 12:43:59 PM »
Hmmmm, sounds difficult. I will try to experiment a little.
Can you also try to figure it how to do it?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Rabagast

  • Hero Member
  • *****
  • Posts: 623
    • View Profile
    • Homepage
Re: Rotate a cube
« Reply #29 on: October 16, 2013, 01:14:51 AM »
I found a little bug when I click on the first cube. It is possible to click on the same cube one more time after the first click. Then it will find two matching cubes.
I tried to set the layer to default when I'm clicking on it and then set it to water when it's finished and starting over again. But the problem was that it was just the first cube which was changing the layer to default and the second cube was changing back to water which was already water, so it doesn't work. Some ideas?
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no