generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Better method than Magnitude?

Previous Thread :: Next Thread 
MonkSaru is not online. 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 is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
04 Nov 2014 04:26 PM
what do you mean constant
Report Abuse
Discern is not online. 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 is not online. 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 is not online. 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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
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 is not online. 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 is not online. 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 is not online. 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 is not online. anaIyze
Joined: 29 May 2014
Total Posts: 2048
04 Nov 2014 06:26 PM
@robo, that's why we use meshes :]
Report Abuse
robocu3 is not online. 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 is not online. 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 is not online. anaIyze
Joined: 29 May 2014
Total Posts: 2048
05 Nov 2014 07:26 PM
lrn2usemeshesifpartistoobignoob
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image