So, I'm in the middle of making an RTS game. I have a script that places a "selection" part/box on the ground when I click, which is where the script will place a "building", for it. Though I also want it to be able to detect if it's conflicting with any other parts/buildings, IE it's being build inside them. I don't have any idea what method I could use to do this, though, and I don't think a touch event would register in this context, since it just spawns the part to the clicked position. Since the part is bigger than where the mouse clicks, I also cannot use mouse.Target.
Is this possible?
EDIT: the 'buildings' will also vary in size, and potentially be rotated at various degrees.
Which restricts some options
Magnitude magnitude is the distance between 2 objects
local magnitude = (part1.Position - part2.Position).magnitude print(magnitude)
http://wiki.roblox.com/index.php/Magnitude
Center of Mass Roblox sets position by the center of mass.
An example is a 5x5x5 brick now the center of mass would be in the middle so it would be 2.5 by 2.5 which means 2.5 left from the border and 2.5 down from the top border http://hyperphysics.phy-astr.gsu.edu/hbase/cm.html
Using them
-- assuming each part1 and part2 is 5x5x5 and the borders are only touching 1 stud in part1.Position = Vector3.new(4,1,4) part2.Position = Vector3.new(4,1,7) centofmass = 5/2 local magnitude = (part1.Position - part2.Position).magnitude if magnitude <= centofmass then print('touching') end