playMaker

Author Topic: Placing objects on a grid and being able to reconfigure their positions  (Read 3107 times)

nomad

  • Playmaker Newbie
  • *
  • Posts: 2
Hi all,

To start, I'm fairly new to unity, playmaker, and have very limited development experience. My background is in 3D and am starting to get familiar with playmaker.

I'm trying to create a Configurator with the following conditions:

- The user starts by selecting from 3 preconfigured setups which each spawn a bunch of prefabs at specific locations on a 4x4 grid. These prefabs are selected from 5 different types of objects (square, circle, etc) with 2 or more variations of each type (square_A, circle_B, etc).

- Each setup must contain 1 of each type of object, but that one object can be any variation.

- After a preconfigured system has been created and the objects are spawned in certain spots on the grid, the user can then begin to swap out new variations of the objects on a "1 in 1 out" basis.

- Some of the objects need 2 slots on the grid, most take up only 1 slot.


My problems start with the objects that need 2 slots. They have to be able to test for and push other objects over to make room.

I'm totally lost and looking for a bit of direction. I don't really understand how use arrays, properly store the right variables, or setup the testing logic. Any help would be appreciated, if only to lead me in the right direction.

Thanks!


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Placing objects on a grid and being able to reconfigure their positions
« Reply #1 on: November 20, 2013, 12:38:28 AM »
Hi,

 We are working with the author of Grid Framework on the asset store to provide playmaker support, I think it will be helping you a lot for what you want to achieve.

https://trello.com/c/ikhSzAzh/21-grid-framework

also, depending on your type of game, you may have also to resort to a proper framework for this, there is a lot of very powerful tile based engines on the asset store, have you done some research on that front?

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Placing objects on a grid and being able to reconfigure their positions
« Reply #2 on: November 20, 2013, 01:47:34 AM »
This is gonna be extremely complex. Grid Framework will help with some of the basic grid setup (although it is possible to create your own in Playmaker using Collision Tracking and Float to Int rounding to snap to exact values).

For the 2 slot problem, you can create an FSM which basically says "If I'm colliding with this object, add 1 to my X/Y/whatever and set my position there" using the CollisionDetection and variable rounding. But again, this will not be a piece of cake. Grid Framework will only (last time I used it) snap objects to their relative close positions if intersecting and snap objects to exact X,Y positioning.

As for arrays, get cozy with ArrayMaker, it'll be your best friend. Once you learn their power you'll never go back. For spawning, you can use something like "PoolManager" to help keep your performance from ballooning.

Good luck my friend!

nomad

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Placing objects on a grid and being able to reconfigure their positions
« Reply #3 on: November 20, 2013, 03:58:50 PM »
Thanks, guys. Grid framework looks interesting, the playmaker integration would be sweet. I'm going to play with it a bit and see how it goes.

Currently, I had a bit of success creating an array representing all the slot locations. Then manual adding the objects to make up the pre-configurations. I used a forLoop to run down the list, checking for what object was in what index, and spawning them at the corresponding slot location.

Hopefully, testing out Grid Framework can spark some ideas how to handle the rearranging.

Playmaker's been a blessing. I'm actually learning programming concepts.  :)