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
 

How to make a region around a block.

Previous Thread :: Next Thread 
mightybaseplate is not online. mightybaseplate
Joined: 28 Aug 2010
Total Posts: 7660
03 Mar 2016 11:06 AM
I'm working on some AI, and I want to be able to move blocks around and have them be regions.

I want to be able to resize the blocks, and when the game starts, it turns that block into a region.

Report Abuse
RottenWraith is not online. RottenWraith
Joined: 16 Aug 2008
Total Posts: 1587
03 Mar 2016 11:19 AM
part = game.Workspace.Part
local part_size = part.Size
local part_position = part.Position
local start_point = part_position + Vector3.new(-part_size.X/2, -part_size.Y/2, -part_size.Z/2)
local end_point = part_position + Vector3.new(part_size.X/2, part_size.Y/2, part_size.Z/2)
local region = Region3.new(
Vector3.new(
math.min(start_point.X, end_point.X),
math.min(start_point.Y, end_point.Y),
math.min(start_point.Z, end_point.Z)
),
Vector3.new(
math.max(start_point.X, end_point.X),
math.max(start_point.Y, end_point.Y),
math.max(start_point.Z, end_point.Z)
)
)
Report Abuse
mightybaseplate is not online. mightybaseplate
Joined: 28 Aug 2010
Total Posts: 7660
03 Mar 2016 11:29 AM
thanks
Report Abuse
mightybaseplate is not online. mightybaseplate
Joined: 28 Aug 2010
Total Posts: 7660
03 Mar 2016 11:57 AM
Why part_size/2?
Report Abuse
RottenWraith is not online. RottenWraith
Joined: 16 Aug 2008
Total Posts: 1587
03 Mar 2016 01:53 PM
The parts position is the center of the part. And the parts size is the entire length of the part. So if we are only trying to go to the edge of a part, since we are starting from the center, we only need to go to half of its size, rather than the whole size
Report Abuse
mightybaseplate is not online. mightybaseplate
Joined: 28 Aug 2010
Total Posts: 7660
03 Mar 2016 02:51 PM
okay thanks
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