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: Need an efficient way for Detecting onTouch

Previous Thread :: Next Thread 
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Jan 2013 08:55 PM
So, I was building in my game, a script that combines two Electrons When they touch. They are small though. My script detects big objects however, it doesn't detect my small electrons.

My electrons are Anchored, and are moved by a script using CFrame. I'm wondering if CFrame stops it from detecting the onTouch.

Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
24 Jan 2013 09:19 PM
CFrame and onTouch don't mix well. :/
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Jan 2013 09:22 PM
How should I do this then?
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
24 Jan 2013 09:24 PM
That's a good question.
I have not tried to find the answer yet.
I wish I could help you. :/
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
24 Jan 2013 09:27 PM
"CFrame and onTouch don't mix well"

What? You're comparing a property to an event. Touched event activates when a part touches whatever is connected.

Just use a Touched event. CFrame won't affect it unless you pass the part without it being touched
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Jan 2013 09:27 PM
Well this is a pickle.
I could use a while loop, to detect if it's really close to another electron.
But while loops are kind of laggy. The reason Why I want them to collide is because of lag. It reduces the number of electrons.
So I think a while loop would be counter productive.
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Jan 2013 09:29 PM
@miz
the Touched event won't detect other electrons, but will detect anything else. I think It has to do with the fact that their being moved by CFrame.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
24 Jan 2013 09:32 PM
@miz, when a part is being constantly moved through CFrame, onTouch doesn't detect that part. :/
Any solutions?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
24 Jan 2013 09:35 PM
Never actually used this before, but Region3 may work. http://wiki.roblox.com/index.php/IsRegion3Empty_%28Method%29
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
24 Jan 2013 09:41 PM
Hmmmm, this is strange.

I set a part to constantly move and set any part it touches to the color red.

It set my character's parts to red, but not the base.
What could this mean?
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
24 Jan 2013 09:43 PM
But would using a while loop aside with region3 lag more than just having no collision?
There are going to be a bunch of electrons.
If I used a while loop, I don't know if it will lag a lot or not.
Report Abuse
MainDirectory is not online. MainDirectory
Joined: 20 Dec 2012
Total Posts: 1834
25 Jan 2013 02:09 AM
Why do you not just attempt using magnitude?
Report Abuse
shred1894 is not online. shred1894
Joined: 30 Aug 2009
Total Posts: 6515
25 Jan 2013 02:33 AM
Try using magnitude and tables.

It feels a tad hacky to do it that way, but it works.



S-1894>(Supreme_Commander_of_Advanced_Zero)
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
26 Jan 2013 10:55 PM
I use magnitude to move the darn things.
What to you mean by "use magnitude"?
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
27 Jan 2013 04:58 PM
if (part1.Position - part2.Position).magnitude <= 0 then
print("touching")
end
Report Abuse
databrain is not online. databrain
Joined: 01 Jan 2013
Total Posts: 3342
27 Jan 2013 05:26 PM
already did that. it works.
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