MonkSaru
|
  |
| Joined: 29 May 2010 |
| Total Posts: 166 |
|
|
| 04 Nov 2014 04:15 PM |
| I need a better method for finding a players distance that is constant. I'm making an area capture system and i need to be able to tell if the player left the area, if another player joined in the area or if there is no one in the area. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
| |
|
Discern
|
  |
| Joined: 02 Feb 2013 |
| Total Posts: 331 |
|
|
| 04 Nov 2014 04:29 PM |
just use a while loop if you want it to be constant
-[=[Discern || Inferno Order Soldier || Graphics Designer || Trader || Game Developer || Clan Man]=]- discernrblx.deviantart.com |
|
|
| Report Abuse |
|
|
MonkSaru
|
  |
| Joined: 29 May 2010 |
| Total Posts: 166 |
|
|
| 04 Nov 2014 04:36 PM |
| I did use a while loop for it and its not fast enough. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Nov 2014 05:25 PM |
| If you want to detect people almost right away, use invisible parts. Checking if someone is near 30 times a second is very inefficient. |
|
|
| Report Abuse |
|
|
|
| 04 Nov 2014 05:27 PM |
| Cntkillme correct me if I'm wrong (I could be) but wouldn't invisible parts cause unnecessary lag? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Nov 2014 05:31 PM |
Not really if they are anchored (sleeping parts) and is only 1 part (I mean if you have a whole bunch of parts then that's a different story).
Since you just listen for the Touched event, which is handled by an internal loop, you don't have to create a loop and use the GetPlayers method a bunch of times and iterate a bunch of times. But then again, if you are checking for players every 0.5 seconds or more, there is no point in using an invisible part. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 04 Nov 2014 05:34 PM |
What if it's a zombie? @cnt, humanoids don't function well with giant parts welded to them lol
-=Robo=- |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Nov 2014 05:36 PM |
| If a zombie walked through the part it would still trigger the touched event, I don't see how welds have anything to do with this? |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 04 Nov 2014 06:26 PM |
| @robo, that's why we use meshes :] |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 04 Nov 2014 07:08 PM |
lol neither of you interpreted correctly assume he was doing this with a loop to check the distance from a player and an NPC, a pseudo part wouldn't work because humanoids misbehave when they're scaled up, and @analyze, yeah, figured someone would say that cx meshes don't fire upon collision unless you're touching the adorneed part itself
-=Robo=- |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 04 Nov 2014 07:10 PM |
| Can you post the code that isn't fast enough? Because .magnitude most certainly isn't your problem. |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 05 Nov 2014 07:26 PM |
| lrn2usemeshesifpartistoobignoob |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 07:28 PM |
Really? Do you need to do this 30 times per second? http://blog.roblox.com/2012/05/using-wait-wisely/ |
|
|
| Report Abuse |
|
|