Unknown command setLinearVelocityY???
by John Walsh · in Torque 2D Beginner · 07/01/2013 (7:50 am) · 4 replies
Hey I'm new to Torque 2D, having only been messing around with it for under a week. I've created an image and my background and now I'm trying to connect controls to the image. When I load up my .exe, the image doesn't move and the log file says:
Here is the contents of the controls.cs:
Does anybody know what could be wrong?
If you need the player.cs I can provide that too.
Thanks.
modules/myModule/scripts/controls.cs (23): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (27): Unknown command setLinearVelocityX. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (39): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (31): Unknown command setLinearVelocityX. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (19): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (35): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (47): Unknown command setLinearVelocityX. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (23): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (43): Unknown command setLinearVelocityX. Object InputManager(1147) InputManager -> ScriptObject -> SimObject modules/myModule/scripts/controls.cs (39): Unknown command setLinearVelocityY. Object InputManager(1147) InputManager -> ScriptObject -> SimObject
Here is the contents of the controls.cs:
function InputManager::Init_controls(%this)
{
new ActionMap(goblincontrols);
$Goblin = %this;
goblincontrols.bindCmd(keyboard, "w", "GoblinUp();", "GoblinUpStop();");
goblincontrols.bindCmd(keyboard, "s", "GoblinDown();","GoblinDownStop();");
goblincontrols.bindCmd(keyboard, "a", "GoblinLeft();","GoblinLeftStop();");
goblincontrols.bindCmd(keyboard,"d","GoblinRight();","GoblinRightStop();");
goblincontrols.push();
}
function GoblinUp()
{
$Goblin.SetLinearVelocityY(-15);
}
function GoblinDown()
{
$Goblin.SetLinearVelocityY(15);
}
function GoblinLeft()
{
$Goblin.SetLinearVelocityX(-25);
}
function GoblinRight()
{
$Goblin.SetLinearVelocityX(25);
}
function GoblinUpStop()
{
$Goblin.SetLinearVelocityY(0);
}
function GoblinDownStop()
{
$Goblin.SetLinearVelocityY(0);
}
function GoblinLeftStop()
{
$Goblin.SetLinearVelocityX(0);
}
function GoblinRightStop()
{
$Goblin.SetLinearVelocityX(0);
}Does anybody know what could be wrong?
If you need the player.cs I can provide that too.
Thanks.
About the author
#2
Here is the player.cs:
07/01/2013 (8:29 am)
The $Goblin = %this was from something I was trying earlier, seems I forgot to remove it, I've removed it now and I'm getting a new error message:modules/myModule/scripts/controls.cs (24): Unable to find object: '' attempting to call function 'setLinearVelocityX' modules/myModule/scripts/controls.cs (20): Unable to find object: '' attempting to call function 'setLinearVelocityY' modules/myModule/scripts/controls.cs (36): Unable to find object: '' attempting to call function 'setLinearVelocityY' modules/myModule/scripts/controls.cs (40): Unable to find object: '' attempting to call function 'setLinearVelocityX' modules/myModule/scripts/controls.cs (20): Unable to find object: '' attempting to call function 'setLinearVelocityY' modules/myModule/scripts/controls.cs (36): Unable to find object: '' attempting to call function 'setLinearVelocityY'
Here is the player.cs:
function createPlayer()
{
%player = new Sprite(Goblin);
%player.setBodyType( dynamic );
%player.Position = "0 0";
%player.Size = "7 7";
%player.SceneLayer = 1;
%player.Image = "myModule:goblin";
%player.createPolygonBoxCollisionShape();
%player.setCollisionCallback( true );
myScene.add( %player );
}
#3
07/01/2013 (8:32 am)
I've been confused by this and I'm not sure if this will work but try removing the $ from Goblin in the control scripts. I don't think global variables and object names are one in the same.
#4
07/01/2013 (8:34 am)
You were right! Thanks a lot :)
Anthony Green
Actually, after looking over this again, why do you set $Goblin = %this?