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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Question:

Previous Thread :: Next Thread 
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
17 Aug 2013 05:05 AM
What is the most efficient way to have something happen when a player is close enough to an object? I do not want to be looping through the player list and checking their distance from this object, as there will be probably 15 or 20 different objects, and I feel that would cause a lot more lag.

Any replies are very much appreciated.
Report Abuse
Cakins is not online. Cakins
Joined: 23 Jul 2009
Total Posts: 307
17 Aug 2013 05:07 AM
Depends; are the objects stationary? Are the players in constant motion?
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
17 Aug 2013 05:07 AM
Players are in constant motion, objects are stationary. Thank you for the quick reply.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
17 Aug 2013 05:08 AM
Well you may not want to loop through the player list, but you will always have a distance when working with stuff like this, if you are completely against looping through the player list, use raycast.
Report Abuse
Cakins is not online. Cakins
Joined: 23 Jul 2009
Total Posts: 307
17 Aug 2013 05:11 AM
I can think of three ways of doing it, ranging from easy to hard, though also ranging from inefficient to efficient.

Check ranges at all times position relative to players, rather than player's position relative to objects.

Create a field of parts in some manner around the stationary parts that would enable .Touched to positioning when things get close.

Using raycasting.
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
17 Aug 2013 05:12 AM
Yes I could do that. Also I have no been on roblox for quite an amount of time, so I am not aware of recent updates.
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
17 Aug 2013 05:16 AM
The second option is what I was thinking of doing.
I am not very familiar with ray casting, but essentially I would cast a ray from the character's lets say torso, to the object, and then measure the distance of that ray?

But isn't that essentially the same things as just looping through the players and calculating the distance between the object and the player?

Sorry I am a bit of a beginner, and I require a bit more explanation.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
17 Aug 2013 05:18 AM
No, you would make a ray wherever you want, then use the method findpartonray to see if anything touches the ray, then use conditions to see if it is a player.
Report Abuse
Saodo is not online. Saodo
Joined: 26 Jul 2011
Total Posts: 1206
17 Aug 2013 05:18 AM
so you are alive .... :L
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
17 Aug 2013 05:19 AM
Who? ^^
Report Abuse
canada1232111 is not online. canada1232111
Joined: 16 Jan 2013
Total Posts: 863
17 Aug 2013 05:19 AM
@ark depending on how you do it, your raycasting idea would be less laggier.
Report Abuse
Arkose is not online. Arkose
Joined: 26 May 2013
Total Posts: 745
17 Aug 2013 05:21 AM
He was referring to me. Yes I understand what I have to do with the ray casting , thank you for the replies everyone.
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