Wall Sidle Fail

Okay, I have this python code:

import bge

def main():
scene = bge.logic.getCurrentScene()

cube1 = scene.objects["Wall"]
cube2 = scene.objects["Guy"]

cube2.worldOrientation = cube1.worldOrientation

I set the python controller to “module”, and put .main on the end of the title. I applied this to a cube (called “Guy”). The idea is to align the cube with whatever wall he touches. But, no matter what, the cube always copies the rotation of one of the “Wall” copies, even if I touch another Wall first. I even used the trick of empties set as “groups”, but that didn’t make a difference. Can I make this work? Thanks.

scene.objects[‘Wall’] is not what you need

I think this is closer to what you need

  • bonus here is the alignment to wall happens over x frames *
    #mess with changing the .25 to higher and lower numbers#

Collision----------python

import bge
cont = bge.logic.getCurrentController()
own = cont.owner()

Collision = cont.sensors['Collision']

if Collision.positive:
   own.alignAxisToVect(Collisision.hitObject.worldOrientation.col[0],0,.25)
   own.alignAxisToVect(Collisision.hitObject.worldOrientation.col[1],1,.25)
   own.alignAxisToVect(Collisision.hitObject.worldOrientation.col[2],2,.25)
  

I’m sorry, but this doesn’t seem to do anything, whether it’s a script or a module, an object or an empty.

Collision sensor--------[This python script]
‘Property’ Wall

colliding with wall should point you the same direction the wall axis is facing.

edit: script needed minor edits.

Attachments

PointAtTouchingOrientation.blend (422 KB)

Oh, NOW it works! Great! This is a “matrix” type system, right? I still haven’t figured out how those work, but plugging in that code does the trick, even when I use empties set to “wall” group.

I have been looking for something like this too, thanks BPR!