# playMaker

### Author Topic: Testing if an object is in a position  (Read 469 times)

#### RobotGoggles

• Playmaker Newbie
• Posts: 20
##### Testing if an object is in a position
« on: September 30, 2019, 09:39:59 PM »
I'm working on a tile-based 3D game, and I need to figure out if a floor tile is in a certain position relative to another one. I'm doing this to create a border around the tiles that are on the outer edge. Currently I'm using a series of raycasts when the tile is spawned, but for some reason this only works about 75% of the time, as you can see in the attached image.

Is there a more surefire (and maybe more graceful) way of doing this?
When life hands you insomnia, make video games.

#### Athin

• Full Member
• Posts: 152
##### Re: Testing if an object is in a position
« Reply #1 on: October 01, 2019, 02:50:50 AM »
Heya,

Depending on your setup, I think Arrays are what you are going to want to do.  if the board is 5x5 for example, an array with each tile in order will make it easier for you to find the info you need using the index

For example, if tile at index 17 wants to check if it has neighbor, Have it grab

Current index(17) - board widht(5) = Top(12)
Current index(17) + BoardWidth(5) = Bottom(22)
Current Index(17) - 1 = Left(16)
Current Index(17) +1 = Right(18)

You'll need some sanity checks in play in case you get out of range index numbers but that would be a good start.

Hope that helps.

#### jeanfabre

• Hero Member
• Posts: 15443
• Official Playmaker Support
##### Re: Testing if an object is in a position
« Reply #2 on: October 01, 2019, 04:00:21 AM »
Hi,

you can also simply have actual triggers for each slots.

Bye,

Jean

#### RobotGoggles

• Playmaker Newbie
• Posts: 20
##### Re: Testing if an object is in a position
« Reply #3 on: October 02, 2019, 02:48:03 AM »
Thanks for the responses. I tried setting up an array system tonight, but for whatever reason it made performance take quite a dip, even when the current active state has no actions connected to the array (?) I like that solution though, since it relies more on logic than physics.

I'll try colliders tomorrow...
When life hands you insomnia, make video games.

#### jeanfabre

• Hero Member
• Posts: 15443
• Official Playmaker Support
##### Re: Testing if an object is in a position
« Reply #4 on: October 02, 2019, 03:36:35 AM »
Hi,

Check out the "Three in a row" Sample on the ecosystem ( it needs arraymaker, so install arraymaker first, then that sample)

you'll see a good fsm to learn how to go over a board and check content.

Bye,

Jean