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: Cube Game

Previous Thread :: Next Thread 
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 05:29 PM
So I was just wondering how I would go about creating a game in where blocks/ cubes can be placed, I imagine there has to be a grid of some sort (or at least I would like one) that would show where blocks can be placed.

Pretty much a building game is what I am asking about, something on the basis of Minecraft.
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
03 Jan 2017 05:37 PM
-Learn how to use the concept of 'chunks' for sandbox games (optionally, learn to use the cubic variant)
-Learn surface normals and approximation/rounding (for building and conforming to a grid)
-Learn how to take advantage of the Save/Create Place API
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 05:56 PM
Well I would need chunks if it was a large scale sandbox game, but luckily its not (not a sandbox game btw).
So I am mainly curious with the approximation/ rounding. I don't even know where to begin after finding nothing on google, I did some across vector3 so I will play with that for a bit.
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 06:42 PM
can you please tell me where I can learn about part placement approximation?
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
03 Jan 2017 06:46 PM
local snapTo = 4

local pos = m.Hit.p
cube.CFrame = CFrame.new(math.floor(pos.X/snapTo)*snapTo,math.floor(pos.Y/snapTo)*snapTo,math.floor(pos.Z/snapTo)*snapTo)


something along the lines of that


Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 07:31 PM
Though I am a bit of a noob I managed to figure out something:

wait(3)
local snapTo = 4
local Player = game.Players.LocalPlayer
local m = Player:GetMouse()

game.Workspace.ok.Touched:connect(function()

local cube = Instance.new("Part")
cube.Anchored = true
cube.Parent = workspace

cube.Size = Vector3.new(4, 4, 4)

local pos = m.Hit.p
cube.CFrame = CFrame.new(math.floor(pos.X/snapTo)*snapTo,math.floor(pos.Y/snapTo)*snapTo,math.floor(pos.Z/snapTo)*snapTo)
end)

-------------------------------------------------------
So I was just wondering why don't they stack on top of one another? or even on top other parts. I just kind of pieced together everything I could remember and did a bit of research so it is just the sake of having it to work and polish it up later.

I'm new to CFrame btw, and thanks a lot!
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
03 Jan 2017 07:33 PM
wait(3)
local snapTo = 4
local Player = game.Players.LocalPlayer
local m = Player:GetMouse()

game.Workspace.ok.Touched:connect(function()

local cube = Instance.new("Part")
cube.Anchored = true
cube.Parent = workspace

cube.Size = Vector3.new(4, 4, 4)

local pos = m.Hit.p
cube.CFrame = CFrame.new(math.floor(pos.X/snapTo)*snapTo,math.floor((pos.Y+(snapTo/2))/snapTo)*snapTo,math.floor(pos.Z/snapTo)*snapTo)
end)


idk im guessing


Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 07:36 PM
That did the trick, thank you!
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 07:53 PM
I have encountered a bit of problem that I am not sure is easy to solve:
When placing those blocks (or you can call it relocating) you need to have your mouse pointer over a specific location on the (for example) 4x4 which is the 2x2 part of it on the bottom right corner or something like that to have it spawn right on top.

Otherwise it will spawn next to the block.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
03 Jan 2017 07:56 PM
if i understood what you posted, after each (x or y or z)/snapTo, put +0.5

like this (for Y and Z as well)

math.floor(pos.X/snapTo+0.5)


Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 08:04 PM
Thank you so much!


︵‿︵(´ ͡༎ຶ ͜ʖ ͡༎ຶ `)︵‿︵
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
03 Jan 2017 08:30 PM
I may be pushing my luck with all the questions (sorry!) but I can also build to the side of the cube in the direction of the positive z-axis, x-axis and y-axis.

but if I try to build in the opposite direction of the above ^ (negative direction of axis) (like beneath a part instead of on top) it just spawns in the same location.
Is there a way to prevent the spawning of parts inside each other and in the best case scenario build in all directions?

Thanks!
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
04 Jan 2017 06:20 AM
I figured it out, by making the cube (4.01, 4.01, 4.01)
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
04 Jan 2017 01:03 PM
How would I set a range on the tool, as it stand I can place a block practically on any surface.
Report Abuse
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
04 Jan 2017 01:07 PM
local snapTo = .50 --// To every half stud
local brick.Position = Vector3.new(math.floor(brick.Position.X)+snapTo,math.floor(brick.Position.Y)+snapTo,math.floor(brick.Position.Z)+snapTo)
Report Abuse
DisguisedBlack is not online. DisguisedBlack
Joined: 01 Jan 2015
Total Posts: 194
04 Jan 2017 01:12 PM
Sorry I should have been more specific:

What I'm asking is to make it possible to place blocks as far as 15 (for example) studs away from the player and not any further, as it is right now I can place a block anywhere I click, even if it is 100's of studs away from the player.

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