Game Development Community

Unable to find object - can't find editor-placed static

by Mr Zurkon · in iTorque 2D · 06/09/2011 (1:36 pm) · 1 replies

I've placed a static in TGB that I've labeled with the class CharacterClass (under scripting - class). Here's my function:
function CharacterClass::moveHorizontally(%this, %value)
{
   %this.setLinearVelocityX(%value); 
}

I'm trying to call it by writing:
%CharacterClass.moveHorizontally(10);

Error: game/scripts/game.cs (93): Unable to find object: '' attempting to call function 'moveHorizontally'

Did I miss something here?

#1
06/09/2011 (2:44 pm)
It doesn't work that way. If you want to be able to move that single object, you want to give it a Name, not a class. Then you would call it like this:

CharacterClass.moveHorizontally(10);

If you want to keep it as a class, since other objects might use it, you still need to give it a Name (like Bob):

Bob.moveHorizontally(10);