x


Place cubes? problem with my script :S

Hey guys! :) Im still making on my minecraft likely game. Im trying to make a system to i can place cubes. Like this video shows: http://www.youtube.com/watch?v=mOEUkdob5bQ

I just cant figure out how to make a script witch is placing these blocks right :S

at the moment i got this

var Cube : Transform;

function OnMouseOver() {

renderer.material.color = Color.gray;

if (Input.GetButtonDown("Fire1")) {


Instantiate(Cube, GameObject.Find ("spawn6").transform.position, transform.rotation);

}

}

I made my blocks in 6 parts 1 cube on each side. all these cubes got this script. I made a little spawn cube where they could spawn but its not going great :S. hope you can help me :)

more ▼

asked Aug 01 '11 at 10:31 PM

talibob gravatar image

talibob
1 3 3 3

Minecraft and Minecraft style games dont used blocks to create the world, it is a single mesh that is generated via script and modified by the player.

There is a good thread with examples located here;

http://forum.unity3d.com/threads/63149-After-playing-minecraft...

Aug 01 '11 at 11:47 PM vxssmatty

this is a bit off topic- but what is with the sudden rash of minecraft clones? why are people so hellbent on copying it? it's not like they can make a minecraft clone and suddenly make as much money as notch has made... there's such a thing as 'market saturation' you know :P

Also- on topic: if you simply make a bunch of cubes, you're going to run into performance issues extremely quickly. you would need to generate a mesh by specifying where the vertices should be. It's essentially a giant CSG boolean operation that has very efficient octree culling and optimization.

Aug 01 '11 at 11:52 PM testure
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I don't know if this will help you but this a basic instantiating script

var newObject : Transform;

function Update () { 
    if (Input.GetButtonDown("Fire1")) {
       Instantiate(newObject, transform.position, transform.rotation);
    }
}
more ▼

answered Aug 02 '11 at 03:41 AM

Overlord gravatar image

Overlord
484 68 79 90

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3416
x1725
x297
x101

asked: Aug 01 '11 at 10:31 PM

Seen: 946 times

Last Updated: Aug 02 '11 at 03:41 AM