Game Development Community

Help with custom function

by Pie · in Torque Game Engine · 02/17/2008 (8:39 am) · 1 replies

Im currently trying to create a function that changes the weapon my character has equipped.
The function gets called and the correct message shows up in the console.

However, the weapon doesn't change, and I get an error message stating:

Unknown command: mountImage
Unknown command: setImageAmmo

Ive used these commands in a different file to equip the weapon once the player has been created, so I know they exist.

Heres the function :

function changeWeapon(%obj,%wep)
{

    if (%wep==0)
	{
                //Should equip Crossbow
	echo("Equipping crossbow");
	%obj.mountImage( Crossbowimage, 0 );
	%obj.setImageAmmo( 0, 1 );
	}

    if (%wep==1)	
	{
                //Should equip Rocket Launcher
	echo("Equipping Rocket Launcher");
	%obj.mountImage( RocketLauncherImage, 0 );
	%obj.setImageAmmo( 0, 1 );
	}
}

Any help would be appreciated, Thank You

About the author

Recent Threads


#1
02/17/2008 (10:56 am)
Sounds like %obj isn't being passed to the function correctly. Add some echoes to the function, or use Torsion to inspect what the value of %obj is.