Collision prediction troubles

Hello! This is my first post here, so sorry if it isn’t worded great.

I am trying to make a blender game engine clone of this:

I want to play around a bit with the main mechanic. I have gotten part of it working, but I can’t seem to get collision detection working nicely, and I have been trying this for 2 or 3 days now!

I want to try and predict the point of collision of the game object when placing it down.
In the attached file, I have used Suzanne as the object. Just hit r to pick her up/put her down, you don’t need to be looking at her. You can switch her out with any other object, just put an always logic brick with true level triggering on, and freq set to 0, connected to the ProportionalScale python script.

I have used the static movement system from http://riyuzakisan.weebly.com/mousemove-script.html for movement.
My issues are:

  • It won’t hit the cube, even though the raycaster IS hitting the cube.
  • It sometimes partially clips through walls, even though it raycasts back to the model itself to find how much to move it
  • It sometimes places on the opposite side of the wall to where you place it (when you are close to it and looking at it when placing Suzanne down)

There is an issue with the camera going nuts when looking at an area, that may be the mouselook script, and is not a worry to me. I can attempt to fix that later.

The scaling part is working 100%, so that’s not an issue there. It’s just with the placement.
The rescale function takes a paramater of the object’s new position, and returns its new scale as a vector.
The getBoundingBox function is useless at this point, and has gone through a number of changes to what it does. It currently just sits there doing nothing, but can be useful in debugging.

There are a lot of unused variables in there, as they were made while trying things out, and may still be useful later. If they aren’t I’ll end up removing them.

If anyone here can point me in the right direction here, that would be awesome!

Thanks,
Andrew

Attachments

Forced Perspective Game.blend (729 KB)