Climb Ladders, Trees, Rocks, Walls with TGE 1.5
by Afrim Kacaj · 11/13/2006 (4:42 pm) · 66 comments
Download Code File
This is my first resource so please forgive me in advance. I have been holding on to this code for some time now, hoping to make it better before posting it as a resource. Now that I had to merge it my self to TGE 1.5 I had the opportunity to clean it up a bit. However it still lacks one important feature, you can only enter the climbing state if you are facing the object. Once you get to the top and jump off, it's hard to get back on to climb down (unless you make your ladder longer than needed.)
To implement, merge the attached files with your project. You will need a climbing animation, with vertical transform. Same way you do the running animation with ground transform, you need to do the climbing animation with vertical transform. This will allow the animation speed to change with velocity.
Call the animation anything you want as long as it has the word climb in it and add it to your player.
You will also need an object to climb, you can use any DTS shape. Make sure your DTS has a collision box and as tight to the object as possible. Make the appropriate changes to the ClimbableObjects.cs script file.
i.e change shapefile = "~/data/shapes/ladders/ladder.dts"; to shapefile = "~/data/shapes/YOURFOLDER/YOUROBJECT.dts";
Optional: Add the following code to server\scripts\player.cs after the Armor::onLeaveLiquid function.
Go into the mission editor and place your shape in the mission, make sure that it is in an angle less than 90 otherwise it will not work.
This is my first resource so please forgive me in advance. I have been holding on to this code for some time now, hoping to make it better before posting it as a resource. Now that I had to merge it my self to TGE 1.5 I had the opportunity to clean it up a bit. However it still lacks one important feature, you can only enter the climbing state if you are facing the object. Once you get to the top and jump off, it's hard to get back on to climb down (unless you make your ladder longer than needed.)
To implement, merge the attached files with your project. You will need a climbing animation, with vertical transform. Same way you do the running animation with ground transform, you need to do the climbing animation with vertical transform. This will allow the animation speed to change with velocity.
Call the animation anything you want as long as it has the word climb in it and add it to your player.
You will also need an object to climb, you can use any DTS shape. Make sure your DTS has a collision box and as tight to the object as possible. Make the appropriate changes to the ClimbableObjects.cs script file.
i.e change shapefile = "~/data/shapes/ladders/ladder.dts"; to shapefile = "~/data/shapes/YOURFOLDER/YOUROBJECT.dts";
Optional: Add the following code to server\scripts\player.cs after the Armor::onLeaveLiquid function.
function Armor::onStartClimb(%this, %obj, %ClimbObject)
{
//Dismount the weapon here
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setArmThread("look");
}
function Armor::onEndClimb(%this, %obj)
{
//Remount the previous weapon here
%obj.mountImage(%obj.lastWeapon, $WeaponSlot);
}Go into the mission editor and place your shape in the mission, make sure that it is in an angle less than 90 otherwise it will not work.
#42
Maybe 3D studio does the exporting differently...
07/13/2007 (2:31 am)
Afrim, ok thanks. I actually have working run animation with bounding box and it's exported from blender. It did not require to move the model forward in the blender though, just the bounding box.Maybe 3D studio does the exporting differently...
#43
07/13/2007 (10:27 pm)
Well you dont actually have to move the player forward. But the way I set up my rig, i have the bounding box attached to the player. When i move the player the bounding box follows him, so i dont have to move the bounding box seperately. I find this more accurate since moving the player as he is walking or climbing helps me judge how far he should move based on the number of steps he took or how big of a step he took and the bounding box will be right there with him.
#44
07/13/2007 (11:23 pm)
Thanks for the information Afrim!
#45
07/14/2007 (5:19 am)
Yes thank you Afrim, it works now. I had to change the angle of the ladder, it wasnt 90 but was still too steep.
#46
One very minor issue: When the files were integrated into the TGE 1.5 (clean) compiling caused an error in main.cc @ line 135. The offending line was: "ResourceManager->registerExtension(".uft", constructNewFont);"
I'm not sure if it's just my environment, but simply commenting out this line fixed the problem. If anyone else runs into this ... that's the fix.
Update:
It appears that I'm also getting font-related errors in the console. The following error appears several times throughout the console log:
ResourceObject ::construct: NULL resource create function for 'Arial 13 (ansi).uft'.
If anyone knows the fix, pass it on please. This doesn't seem to do anything negative to the game, it's just disheartening to see errors.
08/01/2007 (6:19 pm)
This works great (ok, as great as it can until I make a climb animation) ... thanks!One very minor issue: When the files were integrated into the TGE 1.5 (clean) compiling caused an error in main.cc @ line 135. The offending line was: "ResourceManager->registerExtension(".uft", constructNewFont);"
I'm not sure if it's just my environment, but simply commenting out this line fixed the problem. If anyone else runs into this ... that's the fix.
Update:
It appears that I'm also getting font-related errors in the console. The following error appears several times throughout the console log:
ResourceObject ::construct: NULL resource create function for 'Arial 13 (ansi).uft'.
If anyone knows the fix, pass it on please. This doesn't seem to do anything negative to the game, it's just disheartening to see errors.
#47
08/10/2007 (9:28 am)
thanks for your great ressource. I have the problem, that when i walk to a climbable object, the player starts to climb, but the animation doesnt change from the run animation to the climb animation, it looks like he runs up the ladder...any ideas? I suppose its a fault in the engine code, the .cs files should be correct.
#48
Thanks in advance for advices.
Bye, Berserk.
.
08/28/2007 (6:09 pm)
What is this (sgObjectShadowMonitor::sgCleanupUnused();) supposed to be back to version 1.4.2?Thanks in advance for advices.
Bye, Berserk.
.
#49
main.cc(135) : error c2065: 'constructNewFont' : undeclared identifier
This is the line in error
ResourceManager->registerExtension(".uft", constructNewFont);
Since I am not a C++ programmer can someone help me out here.
09/11/2007 (9:26 am)
I am trying to add this resource but I get an error on the main.cc when I rebuild.main.cc(135) : error c2065: 'constructNewFont' : undeclared identifier
This is the line in error
ResourceManager->registerExtension(".uft", constructNewFont);
Since I am not a C++ programmer can someone help me out here.
#50
09/11/2007 (9:28 am)
I seen the fix above. Thanks
#51
I uploaded a patch to apply on a clean 1.4.2 TGE install on my website here, and I left this resource's code commented out.
Can you give me some hints on what I done wrong? Thanks in advance for anything.
Bye, Berserk.
.
09/11/2007 (5:50 pm)
Hello. I had some troubles using this resource in my project (see here for details).I uploaded a patch to apply on a clean 1.4.2 TGE install on my website here, and I left this resource's code commented out.
Can you give me some hints on what I done wrong? Thanks in advance for anything.
Bye, Berserk.
.
#52
I havent had time to play with torque lately due to a new family member (baby boy). When I get back into it I plan to update it to TGEA. I am truly sorry that I cannot help any further at the moment.
09/11/2007 (7:57 pm)
Those of you having trouble, please keep in mind that this resource is for torque 1.5 and I havent even looked at it since then. If you try to use it with torque 1.5.2 you should not replace the files with those found in this resource but you should merge them using winmerge.I havent had time to play with torque lately due to a new family member (baby boy). When I get back into it I plan to update it to TGEA. I am truly sorry that I cannot help any further at the moment.
#53
It's just I added a tree (from the stronghold mission) inside the climbable object datablock, wich I'm unable to climb.
Bye, Berserk.
.
09/18/2007 (10:19 am)
The resource compiled fine with no problems at all and was fully integrated without a flaw.It's just I added a tree (from the stronghold mission) inside the climbable object datablock, wich I'm unable to climb.
Bye, Berserk.
.
#54
Or a more generic way of mounting a player to something, traveling along it in an arbitrary direction, and jumping off (ala grinding rails in skateboarding/snowboarding games)?
01/01/2008 (7:55 pm)
Has anyone used this resource to move side-to-side instead of up and down? Or a more generic way of mounting a player to something, traveling along it in an arbitrary direction, and jumping off (ala grinding rails in skateboarding/snowboarding games)?
#55
@Ed, I am also looking for like type on mechanic let me know if you make any progress and I'll do the same.
I'm looking to make ledge hanging and moving side to side on ledges.
01/10/2008 (1:48 am)
I had problems with my animations playing while i was stopped on a climbable surface :{@Ed, I am also looking for like type on mechanic let me know if you make any progress and I'll do the same.
I'm looking to make ledge hanging and moving side to side on ledges.
#56
I download the file and insert this resource in my game..compile..all ok and modify a .cs file stert and all ok..
But when i enter in game and go to my object don't climb i have this in consolle
I have a plat terrain...i have a objcet with 90 degrees but not function the player don't climb why???
Please help me...thanks =(
01/17/2008 (1:44 pm)
Hi i have a problem...I download the file and insert this resource in my game..compile..all ok and modify a .cs file stert and all ok..
But when i enter in game and go to my object don't climb i have this in consolle
"Checking if we are facing item to climb"And the player impact with my object but don't climb...why???
I have a plat terrain...i have a objcet with 90 degrees but not function the player don't climb why???
Please help me...thanks =(
#57
01/18/2008 (5:22 am)
Quote:I have a plat terrain...i have a objcet with 90 degrees but not function the player don't climb why???Most likely because you didn't read the last sentence from the resource description:
Quote:Go into the mission editor and place your shape in the mission, make sure that it is in an angle less than 90 otherwise it will not work.
#58
I am trying to get this resource to work in TGEA 1.7.0.
I have no problem in a single player game, but as soon as I run multiplayer the climbing does not work.
Something is not sent correctly to the clients, but I cannot find exactly where it goes wrong.
Any ideas?
Thanks.
05/18/2008 (7:43 am)
Hello,I am trying to get this resource to work in TGEA 1.7.0.
I have no problem in a single player game, but as soon as I run multiplayer the climbing does not work.
Something is not sent correctly to the clients, but I cannot find exactly where it goes wrong.
Any ideas?
Thanks.
#59
There's a good number of coders more familiar with TGE/A than myself on this thread, and if anyone can shed even a little bit of light on this, I'd be very grateful! :)
08/27/2008 (6:46 pm)
I'm curious as to how one would toggle the ability to climb. For my part, I would like to have the player be able to collide with objects without climbing them unless the ability is toggled. I've tried a number of things from introducing a mCanClimb check to various parts of the code and trying to change the dynamicType mask (which disables climbing- but also all collision).There's a good number of coders more familiar with TGE/A than myself on this thread, and if anyone can shed even a little bit of light on this, I'd be very grateful! :)
#60
Trying to implement this in TGEA 1.8.1, but I have no Main.cc file...
04/07/2009 (3:43 pm)
A little help here...Trying to implement this in TGEA 1.8.1, but I have no Main.cc file...

Torque Owner Afrim Kacaj
When you bring the animation in torque, the engine will ignore the vertical movement and use it to determine the speed of the animation instead.
The speed of the animation is determined by the players up/down velocity * the speed of your animation. If the player stands still, velocity is obviously zero and the animation will not play.
Follow the same procedure as the run animation (I know there are instructions on this website somewhere, because thats how i learned) but instead of moving the player forward you are moving him up.
Take your existing animation and move the player up by the same amount he would have moved if he climed.
Make sure that you have the following options in your sequence object:
Cyclic Sequence = Checked
Ignore Ground Transform = Unchecked <------------this is what i was talking about the whole time, ground transform is what tells the engine how fast to play the animation so that his movement matches his animation. You dont want the player to move 200 meters in the mission but only move his hands up and down once.
off topic, if i had a nice animation for the adam skeleton i would bring you guys another great resource. MELEE! I started a thread about this a while back but had no volunteers or responses. At the same time i started a thread about artists not being as generous as programmers and got plenty of responses.