Game Development Community

dev|Pro Game Development Curriculum

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.

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.

About the author

Recent Blogs

Page«First 1 2 3 4 Next»
#61
04/07/2009 (10:13 pm)
Nicolai,

I hate to sound un-helpful, but since there are massive changes to the file structure, the best thing to is project level search for whatever stock code or functions this pertained to. Its how I did it and it works fine.
#62
04/08/2009 (9:47 am)
I did a search and found the code changes in the included main.cc file to exist in the gameFunctions.cpp. I do believe the only line needed to add was:

Con::setIntVariable("$TypeMasks::ClimableItemObjectType", ClimableItemObjectType);


I've been using WinMerge to combine this TGE resource with my TGEA 1.8.1 and got really close, but have errors:

missionMarker.cpp
..........enginesourceT3Dplayer.cpp(3099) : error C2665: 'Con::executef' : none of the 20 overloads could convert all the argument types
        c:TorqueTGEA_1_8_1enginesourceconsole/console.h(537): could be 'const char *Con::executef(const char *,const char *,const char *,const char *,const char *)'
        c:TorqueTGEA_1_8_1enginesourceconsole/console.h(565): or       'const char *Con::executef(SimObject *,const char *,const char *,const char *,const char *)'
        while trying to match the argument list '(PlayerData *, int, const char [13], const char *, char *)'
..........enginesourceT3Dplayer.cpp(3105) : error C2665: 'Con::executef' : none of the 20 overloads could convert all the argument types
        c:TorqueTGEA_1_8_1enginesourceconsole/console.h(536): could be 'const char *Con::executef(const char *,const char *,const char *,const char *)'
        c:TorqueTGEA_1_8_1enginesourceconsole/console.h(564): or       'const char *Con::executef(SimObject *,const char *,const char *,const char *)'
        while trying to match the argument list '(PlayerData *, int, const char [11], const char *)'

This just looks like a little bit of incompatible code from TGE to TGEA... I don't know what to do to fix it...


The lines causing the error are:
Con::executef(mDataBlock,3,"onStartClimb",scriptThis(), Con::getIntArg(rInfo.object->getId()));
and
Con::executef(mDataBlock,2,"onEndClimb",scriptThis());
#63
06/05/2009 (7:26 am)
I'm using 1.5.2 and the it loads till it hits:
Loading compiled script gamedata/data/shapes/player/player.cs.
then just crashes, any idea what might be going wrong? I tried chaning the setarmthread from look to root and made no difference, so I'm out of idea's.
#64
06/05/2009 (2:17 pm)
Glenn does your console log declare any sort of errors at all? Perhaps a syntax error or such?
#65
06/05/2009 (8:29 pm)
Only a few unrelated GUI errors that's missing image files. I would normally check over the console when crashes happen but when there's no errors its odd.

Perhaps it has something to do with the air control/water control resources I added? Or maybe the different directory that its in (Gamedata). Not likely but possible, I will check over the code to make sure I didn't miss any code I was supposed to add.

Edit: I just remembered I put in a Melee resource as well.
Edit 2: I missed 2 lines of code, I guess thats expected when you're tired

New Problem:

I can climb every DTS shape, as long as the collision is 90+ degrees I can climb it.
#66
07/28/2009 (1:28 am)
You guys may have figured it out but:

@Glenn: I believe the problem is fixed by following the instructions from this comment: http://www.garagegames.com/community/resources/view/11502/1#comment-72535

@Nicolai: You need to just take out the integer argument in each case. For example Con::executef(mDataBlock,2,"onEndClimb",scriptThis()); becomes Con::executef(mDataBlock,"onEndClimb",scriptThis());
Page«First 1 2 3 4 Next»