Minecraft block removal/addition

I’m working on a concept game and a part of it hinges on the block additon/removal system you find in Minecraft style games (I’m sure everyone here’s heard of MC by now…)

Does anyone know how to get this working? I’m sure once I have block adding and removal down I can get things like timing, specific tools etc working myself but it’s the first hurdle I’m falling at.

much appreciated for any help/examples/advice

Can’t you do it with “Add Object” - “End Object” ?

End object yes but I can’t add a static object with add object (or I can’t get it to appear at the right place perhaps) I want to be able to add the object 1 blender unit away from the object I’m clicking on

You can add static objects via the AddObject() function - it works fine, I’m pretty sure.

That will need some scripting. I wont be near my PC for atleast 5 hours, when i get home i wil try to make you a example blend.

Pretty tricky adding an object precisely with a mouse at an unknown location. You could probably click an existing block and have a block added precisely adjacent to it’s North face say. From there you could use L or R keys to move to E,S or W. Up, Down to raise or lower. Right click to delete.

I’d be thinking of using an object as a 3d cursor, like a wire material cube. Something that moves one unit per keystroke. Then use number keys to add a particular type of block or the type that was last selected. Or you could move the cursor with some slick combo of a counter, mouse buttons held down and mousewheel.

Yeah, I’ve done that cursor creation before - I used a Mouse Over sensor on a grid object to have the cursor (and created objects) aligned to a grid. It’s not that hard.

I am home, its time to blend.

Edit:
Block creation done.
Working on removing blocks.

Edit 2:
Removing blocks done.
Working on textures, removing animation and simple player setup.

Edit 3:
The player setup is freaking me out, I lost motivation.
Here is the blend file that should work in your generator.
You made the generator so I think you won’t have a problem understanding the logic behind the script.

I will explain everything later when I have time.

Attachments

Minecraft Block System.blend (148 KB)

I think I know what you are looking for - http://www.youtube.com/watch?v=bmSXiQwoRKU

Download here - http://dl.dropbox.com/u/1860288/minecraft.blend (Remember to disable mip-mapping)

Keys:

move - WASD
jump - Space
create block - right click
delete block - left click
change block type - scroll

Remember, this is in 2.54, it could easily be ported to 2.57.
Also, there’s a bug I forgot to fix from when I was testing something. It doesn’t really do anything bad, it just gives an error in console.

Wow guys both are awesome!! I think between both systems I’ll be able to patch together the perfect thing I was looking for!

I’ll update you when I’m a bit further along (which will take a while as I’m slow and going into exams next week) to let you know what its coming out like, see if it’s something you’d be happy to attach your name to (wouldn’t stick your name on something without permission) and also get the details with which to properly credit you. Thanks a million for the help!!

You guys saved my ass :wink:

BTW i singed up just to download these files :wink: thanks again !!!

Welcome to the community.

Hey im a little late for the party but i still need some help.
I am trying to add static objects with the AddObject logic brick but it adds them in every angle and every position but the one i need. And i saw that someone already answered this question but i couldn’t quite grasp the concept. Can someone explain a little bit more to me how i could achieve this

Hello @EmeraldBro
To make ADDED object have preset rotation :arrow_down:

With [ LOGIC BRICKS ]
You would have to make the object that is spawning objects have a PREDEFINED rotation.
(You can do this by making an ANIMATION with a single key-frame of the desired rotation)

P.S I think you can also alternately use the CONSTRAINT logic brick ( not sure)

With [ PYTHON ]
Put this script on the object that is spawning objects.
(This isn’t the best way in PYTHON, but is the best I could do on short-notice) :slightly_smiling_face:

from bge import *
import math

def main(cont):
    #Put the name of the added object here.
    OBJECT = ""
    #Put here the desired ROTATION_DEGREE here.
    ROTATION = 90
    #You can have as many ROTATION_PRESETS as you want. You just need to create them.
    SPAWNED_OBJECT = logic.getCurrentScene().object(OBJECT, cont.owner)
    SPAWNED_OBJECT.applyRotation([0,0,ROTATION],True)

[ AFTER THOUGHS ]
Hope it helps :grinning:

WOW, This is amazing that helps for the rotation. But the position is still messed up… so i cant figure that out…

@EmeraldBro
Easily fixed.
Use :arrow_down:

applyMovement()

instead of

applyRotation()

[ EDIT ] Use as many

math.radians()

as you need for LOCATION or ROTATION or SCALE.

I tried your scripts and they dont seem to be working. Any ideas?

@EmeraldBro
Try my BLEND file.
Preset_Rotation.blend (120.0 KB)
[ EDIT ] It adds unlimitly but since your just adding 1 object per-time it’s just setting the LOCATION or ROTATION or SCALE once.

Ok i will do that. Hope it works!
Btw Thanks for helping me out!