JayByte
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 626 |
|
|
| 14 Oct 2015 02:02 PM |
Is it possible to determine if partA is to the left or right of partB whatever the angle partB is situated at?
Thanks. |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
| |
|
JayByte
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 626 |
|
|
| 14 Oct 2015 02:05 PM |
| I'm not sure if Raycasting would be able to determine this, let's just say PartA could be anywhere in the map at any angle at any distance away from PartB. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 14 Oct 2015 02:12 PM |
| Magnitude, region 3, raycast. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
JayByte
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 626 |
|
|
| 14 Oct 2015 02:15 PM |
Just reiterating, the two parts could be at any point in the map.
On ROBLOX you can't create a rotated Region3. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 14 Oct 2015 02:18 PM |
| You create the region 3 after you rotate it |
|
|
| Report Abuse |
|
|
JayByte
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 626 |
|
|
| 14 Oct 2015 02:21 PM |
I'm sure that Region3s can only be a 3d Cuboid that isn't rotated; the Wiki backs my point up here: 'This constructor can only create a bounding box. That is, you can't create a rotated Region3, because you can only define two corners of the bounding box.'.
http://wiki.roblox.com/index.php?title=Region3 |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 14 Oct 2015 02:23 PM |
if partB.CFrame:toObjectSpace(partA.CFrame).x >= 0 then --partB is to the right of partA end
for the left, it's just <=
Red Blossoms |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 14 Oct 2015 02:23 PM |
sorry it should just be > or <
Red Blossoms |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:39 PM |
I just made a little testing scenario, it works.
local part = Instance.new("Part", workspace); part.Anchored = true; part.Name = "Part1"; part.BrickColor = BrickColor.Red(); part.CFrame = CFrame.new(math.random(10, 20), math.random(10, 20), math.random(10, 20)) * CFrame.Angles(math.random(10, 20), math.random(10, 20), math.random(10, 20)); part.TopSurface = "Smooth" part.BottomSurface = "Smooth" part.LeftSurface = "Weld" local lV = (part.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector;
local part2 = Instance.new("Part", workspace) part2.Anchored = true; part2.Name = "Part2" part2.BrickColor = BrickColor.Blue(); part2.CFrame = part.CFrame + (lV * 20);
function checkLeft(pos, lookVector) if workspace:FindPartOnRay(Ray.new(pos, lookVector * 100)) then print'found part!' end end
part.Touched:connect(function(hit) checkLeft(part.Position, lV) print'checked' end)
Really, all you need to do is this if you have everything else set up:
``` function checkLeft(part) return workspace:FindPartOnRay( Ray.new(part.Position, (part.CFrame * CFrame.Angles(0, math.rad(90), 0)).lookVector * 100)) end ```
http://www.roblox.com/--item?id=130759239 |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:42 PM |
also, I came across a weird bug!
if FindPartOnRay doesn't find a part, it returns some really weird crap followed by Enum.Material.Air
after some research, there's Enum.Material.Air, Enum.Material.Water, Enum.Material.Snow, Enum.Material.Glacier, and Enum.Material.Rock. None of them have valid textures, but they're all in the Material enum. I'm guessing this means ROBLOX is adding them in soon u_u
http://www.roblox.com/--item?id=130759239 |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2015 02:53 PM |
Edit: nevermind, I found out those materials (except air, I dunno what the heck that is) are used for Smooth Terrain.
http://www.roblox.com/--item?id=130759239 |
|
|
| Report Abuse |
|
|