Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 05:30 PM |
This is more of a thought board question then specifically the scripting side. I don't want to reinvent the wheel if there's a better way. I want to keep track of the area of the map a character is and how many people are in that area.
Should I be writing a script that keeps track of players positions, invisible barriers that keep track of who walks through them, or is there a better option? |
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
| |
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
| |
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 06 May 2016 07:08 PM |
| What defines these "areas"? If they are not rectangles or circles (easy geometry) then creating barriers that tags players with the area they are in would be the better option. |
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 07:16 PM |
| It's not easy geometry unfortunately. I was thinking the same, but wondering how others would or have handled this situation. |
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 06 May 2016 07:25 PM |
| Well actually, if you can define your regions as a bunch of lines to make up a rough polygon, you can do some math to figure out if they are within the region. Per wikipedia, if you can cast a ray through the player's position and check how many intersections with the lines of the polygons there are then if it's odd, the player is inside, if it's even they are outside the polygon. |
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 07:45 PM |
| Now thats starting to sound like more work than necessary lol. |
|
|
| Report Abuse |
|
|
| |
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
| |
|
|
| 06 May 2016 07:47 PM |
well, with region3 you can define a square region with 2 corners(using some rather simple math)
and then you can use the method FindPartsInRegion3(check the wiki)
you could iterate through the list created by that to find characters, i think
|
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 07:53 PM |
| That sounds a lot more like what I was looking for. Thanks I'll look into it. |
|
|
| Report Abuse |
|
|
|
| 06 May 2016 07:54 PM |
one last important thing, findparts method only takes a max of 20 parts, so you need to limit your server capacity to 20, and use the ignoreDescendants argument to not include parts in your map
|
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 08:19 PM |
| It says you can change the max parts with maxParts. But not sure how to use the ignoreDescendentsInstance. |
|
|
| Report Abuse |
|
|
|
| 06 May 2016 08:21 PM |
it's not as complicated as it sounds(unless it is, check me on that)
also, i didn't know you can change maxParts
if you just put game.Workspace.Part for the iD argument it would ignore that(i think)
but i think if you also put game.Workspace.Model it would ignore all parts in the model(again, i may be wrong here)
|
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 06 May 2016 08:40 PM |
| So you think a table could work for the parameter. |
|
|
| Report Abuse |
|
|
|
| 06 May 2016 08:42 PM |
you would have to try
if it doesn't, you could try iterating through the table
|
|
|
| Report Abuse |
|
|