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: Positioning a brick on-top of another brick.

Previous Thread :: Next Thread 
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 04:45 PM
Set the position to mouse.Hit.p, Roblox will move it on top for you
Report Abuse
ford1015 is not online. 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
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
21 Aug 2016 04:45 PM
You can use TargetSurface to find out which axis of the Size vector3 it should add
Report Abuse
ClassicalGod is not online. ClassicalGod
Joined: 26 Sep 2008
Total Posts: 2842
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
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
cpmoderator12345 is not online. cpmoderator12345
Joined: 26 Jan 2013
Total Posts: 15651
21 Aug 2016 04:53 PM
add 1 to the y position and math.floor it
i hope you're using cframe
Report Abuse
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
21 Aug 2016 04:58 PM
situation***
bricks***
bricks***
Parts***
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 04:58 PM
TargetSurface will work fine if you want it to position to the side or whatever
Report Abuse
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
FrozenSmite is not online. FrozenSmite
Joined: 17 Jul 2013
Total Posts: 2242
21 Aug 2016 05:02 PM
Use CFrame
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
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
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 05:05 PM
Vector3.FromNormalId***
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 05:05 PM
otherPart.Position = part.Position + worlddir * worldoff**

ffs the typos
Report Abuse
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
21 Aug 2016 05:05 PM
Flux thanks I'll test that.
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
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
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 05:26 PM
Nope it still seems off... blah
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
21 Aug 2016 05:38 PM
diroff should be math.abs(part.Size:Dot(objdir))/2 not worlddir
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