playMaker

Author Topic: Using a top-level Rect to find objects  (Read 2849 times)

mweyna

  • Full Member
  • ***
  • Posts: 242
Using a top-level Rect to find objects
« on: July 09, 2013, 03:39:56 AM »
So I have a dynamic spawned Rect value, but can't seem to find any Playmaker action that can find all objects in those ranges on a macro level. Rather, it seems the only way to do it is to have every individual object itself check "Am I inside this Rect Field?". If there an action to grab all object names with a specificed tag within a Rect Field?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using a top-level Rect to find objects
« Reply #1 on: July 09, 2013, 04:20:13 AM »
Hi,

 in ArrayMaker, I made a sample that select objects within a rect.

https://hutonggames.fogbugz.com/default.asp?W715

Check out the "RTS Selection" sample.

bye,

 Jean

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Using a top-level Rect to find objects
« Reply #2 on: July 09, 2013, 12:29:12 PM »
So within RTS Selection, you have an FSM on each cube called CheckContained, which works beautifully. However, within the context of my scenes I have too many objects to mimic that object-level FSM without seriously affecting my Frames per second. What I've been looking to do is mimic that selection logic, except rather then each "cube" checking it's own position against the RectField, to have a scene level FSM that check's the positions of all cubes against the RectField. So one FSM instead of 4 in the context of your RTS Selection file. If that makes sense. Within the ArrayMaker/ArrayList actions, or even the default Playmaker actions, I can't seem to find anything which would allow me to check a range of coordinates against a range of objects. Something that would "Find all objects with this tag in this Rect field" or even "get all Indexes of options within this Rect field".

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Using a top-level Rect to find objects
« Reply #3 on: July 10, 2013, 03:35:25 AM »
Solved it. Here's how.

On a top-level object, I created an Array of all game objects generated on the grid, in this case "BaseBlock." This was in addition to an Array that contained all the positions to generate them at. Then I had my selection logic, that basically on Mouseclick stored the points of Corner01 and Corner02. It would then calculate a Rect based on those two points, given the multiple ways though that you could create a Rect, I needed to script up all various directions and apply slight math tweaks to account for those directional changes. Here's an image -


Then on that same selection logic, created another FSM that basically would using the Index of the Array that contained all my geometry, check each other against the Rect, and if it was contained in that area would do an action.

Using a 400 object grid (20x20 boxes) I was getting about 15-20 FPS during run-time when I tried doing this all on an object level FSM. By moving it to this top-level approach, I'm now getting about 400 FPS during run-time.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using a top-level Rect to find objects
« Reply #4 on: July 10, 2013, 05:27:41 AM »
Hi,

 Very good!!!

Bye,

 Jean