Ledge Hanging Position Problem

Hey everyone, instead of writing an entire post, I’ll just post a video where I talk and explain the problem.

Here is the video:
http://www.youtube.com/watch?v=JhwqT7kbyNE

A brief description is that:
I want to the set the character to ledge hang, but I want his hands to be touching the ledge. So I just need to copy the y and z of the ledge, where y is how close the character to the ledge, and z where on the Z the character is hanging.

But when I set the position to the y and the z of an empty, it also sets the X so it always centers the character where the empty is on the ledge…

Any ideas?

It is always a little bit hard for me to find a fault without debugging the code. But I think the fault is that you subtract of the world coordinate position of the Empty from the world coordinate position of the player. So try to use lx = test [0] for the ledge on the x axis and lx = test [1] for the ledge on the y axis.

That would work perfectly… For only those 2 sides. Any other side, there would be glitches, I need a script that works for all angle of sides.

If you want to see my script here it is:


	
	ledge = objects[hitobj_p]
	
	lpos = ledge.position
	
	
	lposx = own.position[0]
	
	lposy = own.position[1]
	lposz = lpos[2]
	
	lx = 0
	ly = -box_width + fix_w
	lz = -box_height - fix_h
	
	
	own.worldPosition = Vector([lposx,lposy,lposz])
	
	own.worldPosition = own.worldPosition + Vector([0,0,lz]) + own.worldOrientation * Vector([lx,ly,0])
	
	
	own.orientation = ledge.orientation
	own.suspendDynamics()
	cont.activate(hang)
	own['ledged'] = True
	
if own['ledged'] == True and OR(climb_positive) and own['pressed_climb'] == False:
	cont.deactivate(hang)

	cx = 0
	cy = 1.1
	cz = box_height*2.065

	
	own.worldPosition = own.worldPosition + Vector([cx,0,cz]) + own.worldOrientation * Vector([0,cy,0])
	
	cont.activate(climb_up)
	
	own['pressed_climb'] = True
	
if own['ledge_climb'] == 50:
	own['ledged'] = False
	own['pressed_climb'] = False
	cont.deactivate(climb_up)
	bones = climb_up.owner
	
	bones['ledge_frame'] = 0
	own.restoreDynamics()
	cont.activate(state_main)

I hope you understand it… Right now I am trying to use a constraint to move the bounding box close to the ledge.

This is script is a littel bit different from that in the video. I look at it, but I can’t find the fault. Do you have an exampe blend file (with the actual script) that you can post. So I can try to fix the problem.

Hey, thanks, but I managed to fix the problem…

What I did was, once I set the orientation to the empty for the ledge hang, I got the distance between the hit position of the ray and the bounding box, I moved it all the way, and then I subtracted some of the distance so it would look like he’s hanging on to the edge. Now everything works perfectly.

Bye!