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 » Scripters
Home Search
 

Re: Most efficient way to check a model's part's collision?

Previous Thread :: Next Thread 
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
20 Jan 2017 08:54 PM
I have a script that basically moves a model via bodyPosition, how can I most efficiently check it it hits anything?
Report Abuse
Swozu is not online. Swozu
Joined: 01 Sep 2013
Total Posts: 17
20 Jan 2017 09:36 PM
Put a script inside a part and the contents being this:

script.Parent.Touched:connect(function(hit)
print(hit.Name)
end)

--Hope this helps.


Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
27 Jan 2017 11:12 AM
First off, thats really vague. I already know how to do a for loop and give each part a .Touched event however my problem lies in how do I know when/if it is no longer colliding with something?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
27 Jan 2017 11:13 AM
TouchEnded


Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
27 Jan 2017 01:03 PM
could I get some pseudo code? heres part of my code:

function weldModelToPreview(ogModel)
destroyPreviewModel()
local model = ogModel:Clone()
lastModel = model
model.Parent = Preview.Parent
model:SetPrimaryPartCFrame(Preview.CFrame)
local parts = model:GetChildren()
for i = 1, #parts do
if parts[i]:IsA("BasePart") then
if parts[i].Transparency > .8 then
parts[i].Transparency = .8
end
--parts[i].BrickColor = BrickColor.new("Lime green")
parts[i].Anchored = true
weldBetween(Preview,parts[i])
parts[i].Anchored = false
parts[i].CanCollide = false
end
end
end
Report Abuse
sircfenner is not online. sircfenner
Joined: 29 Aug 2008
Total Posts: 2430
27 Jan 2017 02:13 PM
For your purposes, the Touched and TouchEnded events are probably what you are looking for. If you are dealing with spheres, consider checking magnitudes. Otherwise you may find a good algorithm online which is much more reliable than the not-very-reliable events mentioned above.
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
27 Jan 2017 04:08 PM
My problem lies in the fact that i have multiple parts acting as one. I need to make sure none of them are clipping anything
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
28 Jan 2017 12:12 AM
bump
Report Abuse
Raildex is not online. Raildex
Joined: 06 Dec 2009
Total Posts: 934
29 Jan 2017 04:34 PM
bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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