Game Development Community

trouble with dynamic speed variable in c++

by WestWood_Online (#0004) · in Torque Game Engine · 06/16/2009 (2:38 pm) · 3 replies

ok, so i followed the tutorial: http://www.garagegames.com/community/blogs/view/2698 to a T making sure to just plain get that working before moving on to other variable attributes i wanted to get going.

The problem is that after following the tutorial and rebuilding TGE i run the game with the code

function updateMods(%this){
   
   if(%this.class == 1){
      
      //will increase damage and health later
      
   }
   else if(%this.class == 2){
      
      %maxEnergy = %this.baseMaxEnergy + %this.shieldModifier;
      %speedf = %this.baseMaxForwardSpeed + %this.speedModifier;
      %speedb = %this.baseMaxBackwardSpeed + %this.speedModifier;
      %speeds = %this.baseMaxSideSpeed + %this.speedModifier;

      %this.setMaxSpeed(%speedf,%speedb,%speeds,%speedf,%speedb,%speeds);
      
      //will also include shield upgrades later
      
   }
   else{
      echo("invalid class");
      return;
   }
   
}

and when my player levels i look at the console to make sure everything is hunky dory and i get an error that says that it cannot find setMaxSpeed which should be a console command.

I posted a comment on the resource page too but it doesn't look like it's been active for a couple years now so i don't think i will likely get a reply there...

any help would be greatly appreciated

#1
06/16/2009 (3:07 pm)
ok the engine side i presume is correct. But its the way you are naming the scripts. I hope someone else comes and explaions this because i am terrible at it but the function you have created is incorrect for how you are trying to use it
torque doesnt know what %this is because you have created a global function. im not sure how you have the rest of your stuff set up but try

function Player::updateMods(%this)

i told you i was terrible at explaining =)
#2
06/16/2009 (3:42 pm)
Well done Scooby, now he's gonna leave the community forever. Happy now?

Nah, just kidding (of course), in fact you're right (of course).

@Westwood, you need to:

// Option 1:
// Change how you are *calling* the function:
updateMods(%client.player)

// Option 2
// Include the namespace in the declaration:
function Player::updateMods(%this)
#3
06/18/2009 (7:37 am)
cool, i'll try the changes and see what i come up with

thanks for the replies!

[EDIT]

well i can't really use the first solution (modifing the function *call*) since i really don't know how to gather that.

The second solution i am trying to get working, but is a problem since the function updateMods(%this) is an ambiguous function, it's on the server side and is made so that i pass it who i am attempting to modify so that the server controls the leveling process and updating the players' attributes while they level (let me know if this sounds like a bad idea lol)

any idea where/how i would get the actual %client instead of the game connection id (i.e. the %this) as that seems like it would be the better choice?