Need help with mousetracking and collision

Hi! I need a little help with what I’m trying to do.

  1. I want the cube to snap on the plain and move the cube by blocks. (Just like Minecraft)
  2. My cube is colliding with the plain and does not appear on top of the plain.

I tried different methods on changing the Physics but still no luck. This is getting a little frustrating, I need some help please.



This is because the origin of the cube is in the middle of the mesh. Therefore placing the cube at the plane will show the cube halfway under the plane. There are several ways to handle this situation.

One option is:

  • Parent the cube to an empty that the cube is on top of the empty.
  • Move the empty rather than the cube

mouseOverSensor.hitPosition helps you to find a position on the plane.

After getting the position on the plane (see above), you can “correct” the position to fit your grid.

An often used method is to round to the next grid coordinate. e.g.

object.worldPosition.x = round(object.worldPosition.x)

assuming you have a grid along x with a spacing of 1BU (Blender unit).

Thank you so much MONSTER!

I got the first one. I was able to move the cube at the top of the plane. I was very happy about it.

However. I’m still new to Python Programming and can’t understand the instructions. Can you please instruct it like what you did on the question? Thank you!!!