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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
| |
|
Raildex
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
| |
|