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: Possible to determine if partA is to the left of partB?

Previous Thread :: Next Thread 
JayByte is not online. 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 is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
14 Oct 2015 02:03 PM
Raycasting, maybe?
Report Abuse
JayByte is not online. 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 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
14 Oct 2015 02:12 PM
Magnitude, region 3, raycast.
Report Abuse
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
14 Oct 2015 02:12 PM
GetTouchingParts()
Report Abuse
JayByte is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
14 Oct 2015 02:23 PM
sorry it should just be > or <


Red Blossoms
Report Abuse
Immacularity is not online. Immacularity
Joined: 21 Jun 2014
Total Posts: 419
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
Immacularity is not online. Immacularity
Joined: 21 Jun 2014
Total Posts: 419
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
Immacularity is not online. Immacularity
Joined: 21 Jun 2014
Total Posts: 419
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
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