help making linxgsl's ledge climb script position global

Hi guys, i used linxgls’s ledge hang/climb example and implimented it into my game, but i need it to work from any direction not just on the Y axis, currently I can only climb from one side of my ledge, i need it to work on ledges approached from any angle.

here’s the code as it apears and works in my game.

Could i get a hand rewriting it to work from any position.

Thanks in advance, i’m going to make a big update(and possible demo) with voidkeepers once I have some of these character systems working.

Here’s a link to the thread with the example I used and modded to my character.

import GameLogic as g
cont = g.getCurrentController()
own = cont.owner
ledge_find = cont.sensors['ledge_find']
climb = cont.sensors['climb_ledge']
hang = cont.actuators['hang_animation']
climb_up = cont.actuators['ledge_climb_animation']
tonorm = cont.actuators['backtonorm']
climb_positive = climb.positive and climb.tap
if ledge_find.positive:
 hitpos = ledge_find.hitPosition
 hitx = hitpos[0]
 hity = hitpos[1]
 hitz = hitpos[2]
 hity = hity - 1.3
 hitz = hitz - 4
 hitpos = [hitx,hity,hitz]
 own.position = hitpos
 own['ledged'] = True
if own['ledged'] == True and climb_positive and own['pressed_climb'] == False:
 cx = own.position[0]
 cy = own.position[1] + 3
 cz = own.position[2] + 7
 climbed = [cx,cy,cz]
 own.position = climbed
 own['pressed_climb'] = True
if own['ledge_climb'] == 20:
 own['ledged'] = False
# own.state = 5

Sounds like you’ll need to use some basic trigonometry to point towards the direction you need (not a global axis). I’m not going to go through the whole process, but here’s the idea:

You get the direction of the hit, by using math.atan2(objposy - hitposy, objposx - hitposx). Then, you do the same things to move hitposx by the angle of the hit (math.cos() for the x-axis and math.sin() for the y-axis). This all assumes that you are working with the Z-axis being upwards.

wow, that seems more than i,m probably capable of modifying.

I just thought I could make changes for ledges approached from X,-X,and Y axis’s as it works for a character facing the -Y axis already.

Say I have a box with a ledge on it’s Y axis and the character is facing -Y, he does what he needs to. When I put a ledge on any of the other three my character get transported inside the box, and whatnot.

I’ll keep working on it, and see if I can get somewhere, Thanks Joeman16.

P.S. I really have enjoyed your Resources you’ve made and look forward to implimenting a couple.

Here’s a link to the thread with the example I used and modded to my character.

Thanks, I’m trying to make stuff that’s pretty useful. If you don’t want to do the code, you could duplicate it and use if-statements to check for whatever axis the player is approaching the ledge on. But, it will get hairy very fast, and fixing bugs will be difficult after this.

That’s the route I believe I’ll try as I’ve had luck modding if statements in the past. I can write and mod simple code, but my knowledge in python is fledgling at best, which is why I posted here.

Thanks for the help, if any ideas come to mind please post them here as i’ll be checking back, while i to continue to try to make it work.

thanks again.


post deleted to stop redundantcy:) from 2 threads being merged.

Been awhile since i posted( life sometimes gets in the way.), but I’m working on my game again, and was wondering if someone might have another look at this script and mabye help me modify it using if statements as Solarlune(Big fan of his work.) suggested.

Please keep in mind I’m still using 2.49.

post deleted to stop redundantcy:) from 2 threads being merged.

Two threads merged. In the future if you want a thread moved to another forum just report it to the moderation team (small triangle symbol at the bottom of each post)

Thanks Richard, I appreciate it. I’ll do that in the future.