Point and click to remove blocks?

hey im attempting a game like minecraft (minecraft.net) where you mine stones by holding down the mouse button for a certain amount of time, i would like to make the same gameplay i was wondering what the Logic look like or would it be python (i fail at python) or do u know any tutorials that would help me a looked like a few weeks ago and found dick all. thanks pers2981!

You need one “control” object. this can be an empy ot any other object (even the camera).

Mouse sensor in Mouse Over Any mode (no pulses) name it sMouseOver
Mouse sensor in LMK Mode name it sRemoveEvent

connected with this Python script controller:


import GameLogic
 
def main(cont):
  sMouseOver = cont.sensors["<b>sMouseOver</b>"]
  sRemoveEvent = cont.sensors["<b>sRemoveEvents</b>"]
  # process if both sensors are positive only
  if not sMouseOver.positive or not sRemoveEvent.positive:
    return
  
  hitObject = sMouseOver.hitobject
  # process objects with property remove only
  if not "<b>removable</b>" in hitObject:
    return
  hitObject["<b>remove</b>"] = 1
 
main( GameLogic.getCurrentController() )

Give all objects that can be removed a property “removable”. Type and value do not matter.

What happens
These objects get a property “remove” set to 1 when clicked on them.

BTW: The script is untested, I just typed it from my mind. There might be little typos.

Now you can add logic to all this objects to react on the property:
e.g.:

property sensor equals, remove, “1” -> AND -> endObject actuator

this is the simplest form. other options would be to activate a state actuator. Continue with the logic in the other state (explosion, animation, waiting, ending etc.)

I hope it helps.

Thanks, ill give this a try :smiley:

hmmm im so confused on how to do this :stuck_out_tongue: