|
| 21 Aug 2016 04:44 PM |
Using mouse.Hit.p.
For example a move tool, how would I do this?
Part's collide and go into each-other currently, adding SizeY/2 to the Y axis of the brick will fix it when going on-top of other brick's.
TargetSurface won't work to detect the side of the brick in order to fix brick-merging since brick's can be rotated.
How does roblox handle this? What math must be done? |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:45 PM |
| Set the position to mouse.Hit.p, Roblox will move it on top for you |
|
|
| Report Abuse |
|
|
ford1015
|
  |
| Joined: 16 Jul 2012 |
| Total Posts: 1965 |
|
|
| 21 Aug 2016 04:45 PM |
how are you positioning it? do you want it to fit perfectly or hang-over
|
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:45 PM |
| You can use TargetSurface to find out which axis of the Size vector3 it should add |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:47 PM |
I don't suppose you could cheat just do part.position = x
because that usually places stuff ontop |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:49 PM |
If you have a ray pointing towards mouse.Hit would going -(SizeY/2) in that direction fix the merging?
Flux that would work but I have plans for side/side positioning as-well not just on top of bricks. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:53 PM |
add 1 to the y position and math.floor it i hope you're using cframe
|
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:57 PM |
Cp that would be for a Y size of 2 and math.floor just round's, and that's just for the top.
TargetSurface can't be used in this situation's due to rotations.
I believe I'll have to use a ray. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:58 PM |
situation*** bricks*** bricks*** Parts*** |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 04:58 PM |
| TargetSurface will work fine if you want it to position to the side or whatever |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:00 PM |
Flux
But if the part is rotated then the sides wouldn't be accurate when it comes to positioning. |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Aug 2016 05:03 PM |
"But if the part is rotated then the sides wouldn't be accurate when it comes to positioning." Sure it will, you just translate it along the imaginary line that goes through the TargetSurface. I hope I did my math correctly
local objdir = FromNormalId(TargetSurface) local worlddir = part.CFrame:vectorToWorldSpace(objdir) local worldoff = (part.Size:Dot(worldDir) + otherPart.Size:Dot(worldDir))/2 otherPart.Position = part.Position + worlddir * worldiff
|
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:04 PM |
Frozen that's kind of obvious.
These are 2 parts though.
Also how do you copy the rotation and snap a brick to studs like the Move and Copy tools do? |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Aug 2016 05:05 PM |
otherPart.Position = part.Position + worlddir * worldoff**
ffs the typos
|
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:05 PM |
| Flux thanks I'll test that. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:17 PM |
There was a logic problem with mine, had to absolute value it and the variable names super inconsistent.
local objdir = Vector3.FromNormalId(TargetSurface) local worlddir = part.CFrame:vectorToWorldSpace(objdir) local diroff = math.abs(part.Size:Dot(worlddir) + otherPart.Size:Dot(worlddir))/2 |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:26 PM |
| Nope it still seems off... blah |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 05:38 PM |
| diroff should be math.abs(part.Size:Dot(objdir))/2 not worlddir |
|
|
| Report Abuse |
|
|