- Home /
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 :)
$$anonymous$$inecraft and $$anonymous$$inecraft 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-$$anonymous$$ecraft...
this is a bit off topic- but what is with the sudden rash of $$anonymous$$ecraft clones? why are people so hellbent on copying it? it's not like they can make a $$anonymous$$ecraft 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.
Answer by DayyanSisson · Aug 02, 2011 at 03:41 AM
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);
}
}