Raildex
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
|
| 23 Feb 2016 12:54 PM |
So what im doing here is a little unorthodox, Im creating a hollow dummy model that is positioned to the mouses position and then the user can click to create the actual model at that spot. I need to check and see if the dummy block is touching another object so that it prevents you from spawning a model partially inside of another object. Ive marked where my attempt is.
tool = script.Parent local ting = 0
function click(mouse) local brick = Instance.new("Part") brick.Parent = game.Workspace -- This is the "parent container" of your brick. brick.Name = "Part" -- This name has to correspond with the name of your brick on the map brick.Size = Vector3.new(2,3,2) -- This is the size to which you want to change your brick brick.Anchored = true brick.Position = mouse.hit.p end
function move(mouse) if ting == 0 and mouse.hit.p.Y > 1.8 and mouse.hit.p.Y < 2.2 then ting = 1 local brick2 = Instance.new("Part") brick2.Parent = game.Workspace -- This is the "parent container" of your brick. brick2.Name = "Part" -- This name has to correspond with the name of your brick on the map brick2.Size = Vector3.new(2,3,2) -- This is the size to which you want to change your brick brick2.Anchored = true brick2.CanCollide = false brick2.Transparency = .5 brick2.Position = mouse.hit.p wait(.01) brick2:remove() ---- MY ATTEMPT --- brick2.Touched:connect(function(touchedPart) print(touchedPart) end) --------------------------- ting = 0 end end
function selected(mouse) mouse.Move:connect(function () move(mouse) end) mouse.Idle:connect(function () move(mouse) end) mouse.Button1Down:connect(function () click(mouse) end) end
tool.Selected:connect(selected) |
|
|
| Report Abuse |
|
|
Raildex
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
|
| 23 Feb 2016 01:52 PM |
| bump, I really need to get this fixed, can anyone direct me? |
|
|
| Report Abuse |
|
|
Raildex
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
| |
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 23 Feb 2016 05:21 PM |
I would use workspace:FindPartsInRegion3
then, iterate over each part in your dummy, creating a region3 based on that part. For example, if the torso of the dummy was centered at (0,0,0), the region might look like this: Region3.new(Vector3.new(-1,-1,-.5),Vector3.new(1,1,.5)) If you were to plot those two points I used, they would be at opposite corners, because, if you think about it, 2 opposite corners is all you need to construct a rectangular region (keep in mind that Region3's have no rotation).
Hope that made some sense. |
|
|
| Report Abuse |
|
|
Raildex
|
  |
| Joined: 06 Dec 2009 |
| Total Posts: 934 |
|
|
| 23 Feb 2016 05:26 PM |
| How do I use Region3 to check if its hitting another existing tower or a wall. I see that you can create the bow but how do I utilize it? |
|
|
| Report Abuse |
|
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 23 Feb 2016 05:41 PM |
workspace:FindPartsInRegion3(region3, dummy) returns a table of all the parts that intersect the region, ignoring all parts in dummy. There is also a function :IsRegion3Empty I believe, which should also accomplish what you need. There are similar functions like FindPartsInRegion3WithIgnoreList, in case you want to ignore other things (such as the floor).
http://wiki.roblox.com/index.php?title=API:Class/Workspace/IsRegion3EmptyWithIgnoreList |
|
|
| Report Abuse |
|
|