Invalid parameters to set position when using getPosition()
by Ecliptic · in Torque Game Builder · 12/15/2008 (11:59 am) · 3 replies
Hello again guys. I have been making great progress the past few days as you probably could tell since I haven't been posting my usual questions on here :D. I got through the mole tutorials and several others and now I am trying to put that information to use in my own game. So far I have made a lot of head way and things are working great. I hit this one bump that I have been dealing with and I am not too sure why. I have compared my code to that of the mole level and the get.position code looks fine.
When I run my game I get a error saying t2dSceneObject::setPoisition() - invalid number of parameters! Now the problem is definitely the setPosition but it doesn't make much sense to me why it is stating that. I have my spawn points configured through a datablock, its class is set to spawnPoint and there is 3 on the level. I have reduced the spawn points to 1 per level for now to troubleshoot.
Hopefully I can figure this new problem out :) As always I will post what I did wrong for anyone else that runs into a similar problem :)
Thanks again guys
Dane
When I run my game I get a error saying t2dSceneObject::setPoisition() - invalid number of parameters! Now the problem is definitely the setPosition but it doesn't make much sense to me why it is stating that. I have my spawn points configured through a datablock, its class is set to spawnPoint and there is 3 on the level. I have reduced the spawn points to 1 per level for now to troubleshoot.
function BeginnerLevel::spawnImage(%this)
{
// find a spawn point
%spawnPointIndex = getRandom( %this.spawnPointSet.getCount()-1 );
%spawnPoint = %this.spawnPointSet.getObject( %spawnPointIndex );
//Create the new image.
%image = new t2dAnimatedSprite()
{
sceneGraph = %this;
class = "image";
layer = 1;
size = "7 7";
};
//play the loading animation.
%image.playAnimation("LoadSquareAnimation");
//Set the position of the image to the spawnpoints location.
%image.setPosition( %spawnPoint.getPosition() );
}Hopefully I can figure this new problem out :) As always I will post what I did wrong for anyone else that runs into a similar problem :)
Thanks again guys
Dane
#2
echo (%spawnPoint.getPosition());
in just before the setPosition line. Then you can see if it's the setPosition or the getPosition that's causing the problem. I won't be surprised if getPosition returns something invalid.
mmm - is it possible your spawnPointSet is empty? Maybe put an
echo (%spawnPointSet.getCount());
in there somewhere as well just to make sure.
(or step through it with the debugger)
12/15/2008 (12:40 pm)
I'd say to throw anecho (%spawnPoint.getPosition());
in just before the setPosition line. Then you can see if it's the setPosition or the getPosition that's causing the problem. I won't be surprised if getPosition returns something invalid.
mmm - is it possible your spawnPointSet is empty? Maybe put an
echo (%spawnPointSet.getCount());
in there somewhere as well just to make sure.
(or step through it with the debugger)
#3
I apologize for the thread, especially since it has been fixed in such a short time. I messed around for a few hours today trying to figure this out and it was all because I was looking in the wrong area :P.
For testing purposes I threw in the %image.Position() that you mentioned and it could not get the position of the spawn points. Good to know though, seems like that would have also worked... I think it is because you are just pulling the objects position, not setting the position.
Anyhow thanks for the help Patrick! Hopefully one day I will be able to come back here and help others like you guys heh. I feel bad asking all the questions. My name is going to be covering the Scripting section if I am not careful...
Thanks again,
Dane
Edit:
Shaz you are correct. I did those echo statements and came back with no position cordinates. So I figured that the index was empty and it was. Thanks for the valuable input. I didn't know about the other echo statement to check the spawnPointSet. I will have to keep that in mind. Thanks again!
12/15/2008 (12:51 pm)
I found that it was not a problem with the setPosition. It appears it was not able to find the object referenced in the spawnPointSet to pull the position from.I apologize for the thread, especially since it has been fixed in such a short time. I messed around for a few hours today trying to figure this out and it was all because I was looking in the wrong area :P.
For testing purposes I threw in the %image.Position() that you mentioned and it could not get the position of the spawn points. Good to know though, seems like that would have also worked... I think it is because you are just pulling the objects position, not setting the position.
Anyhow thanks for the help Patrick! Hopefully one day I will be able to come back here and help others like you guys heh. I feel bad asking all the questions. My name is going to be covering the Scripting section if I am not careful...
Thanks again,
Dane
Edit:
Shaz you are correct. I did those echo statements and came back with no position cordinates. So I figured that the index was empty and it was. Thanks for the valuable input. I didn't know about the other echo statement to check the spawnPointSet. I will have to keep that in mind. Thanks again!
Torque Owner RollerJesus
Dream. Build. Repeat.