playMaker

Author Topic: Array and Hashtable help please  (Read 3084 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Array and Hashtable help please
« on: August 20, 2017, 04:36:33 PM »
Hi,
I've been trying to learn how to use Arrays this weekend and it's just not making sense in my head. I've looked at Jean's Match 3 example and djaydino Tetris example but I'm still lost.

Are they any good tutorials that cover this?

Something like, if Tetris pieces are falling and land, how do you record their position in an array and then use this data to delete the gameobjects that make up the pieces. Just that part and I think it will finally click in my head.

Thank you!  8)

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 174
    • multiplayer adult fighting
Re: Array and Hashtable help please
« Reply #1 on: August 20, 2017, 05:09:49 PM »
I assume you already check this very basic intro to array and hash? It was quite helpful for me

indie developer of multiplayer adult fighting
http://nakedfighter3d.com

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Array and Hashtable help please
« Reply #2 on: August 21, 2017, 01:57:56 AM »
Hi,

 the best way to tackle arrays and hashtable is to start with no real purpose but just understand what that do.

In your case you should have already a mechanism that knows all the squares for a given piece right? I would assum each square is parented to the piece probably, so what you can do is that when a square is touching the ground, you send a event to its parent, and the parent is then responsible to destroying all it's squares ( including the one that fired the event)

does that make sense? I am not sure you need array and hashtables for this really.

Bye,

 Jean

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7614
    • jinxtergames
Re: Array and Hashtable help please
« Reply #3 on: August 21, 2017, 11:29:02 AM »
Hi,
in the Tetris sample it actually does not record the position but it does add the objects to the list
You can find this on the prefab items (resources/Prefab)
in the add to array state it is adding each child object from the item in the right line(array)

On the 'Game Mangager' in the 'check row' state i just the amount(count) of the objects in each line (array) when there are 10, the line gets destroyed later.

This setup i made is quite intermediate usage, maybe you should look first into some simpler samples / tutorials.

You can find several tutorials on the user tutorial wiki page

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Array and Hashtable help please
« Reply #4 on: August 22, 2017, 03:41:29 AM »
I assume you already check this very basic intro to array and hash? It was quite helpful for me


Yes, I've watched that one, thanks.

Hi,

 the best way to tackle arrays and hashtable is to start with no real purpose but just understand what that do.

In your case you should have already a mechanism that knows all the squares for a given piece right? I would assum each square is parented to the piece probably, so what you can do is that when a square is touching the ground, you send a event to its parent, and the parent is then responsible to destroying all it's squares ( including the one that fired the event)

does that make sense? I am not sure you need array and hashtables for this really.

Bye,

 Jean

Hi Jean, I didn't really have a game idea in mind. I just wanted to teach myself how Arrays/Hashtables work in Unity/PM.

The idea was, how do I track object position in a grid using an Array and then use that array data to destroy the object at a specific position? That is all I'm trying to do really.

Are you saying an Array is a bad way to do this? Should I just use Game Object triggers and Bools? Then a manager to track which Bools are in a line?

Hi,
in the Tetris sample it actually does not record the position but it does add the objects to the list
You can find this on the prefab items (resources/Prefab)
in the add to array state it is adding each child object from the item in the right line(array)

On the 'Game Mangager' in the 'check row' state i just the amount(count) of the objects in each line (array) when there are 10, the line gets destroyed later.

This setup i made is quite intermediate usage, maybe you should look first into some simpler samples / tutorials.

You can find several tutorials on the user tutorial wiki page

Thanks, that makes a bit more sense about what is happening.

I tried to 'reverse engineer' your Tetris example but it's quite a hard thing to do in PM.

I think I've watched most of the PM Array tutorials available now. Maybe it was just a bad way to do what I planned?