Problem making muliple objects (Register object failed?
by Nic Biondi · in Torque Game Engine · 01/24/2004 (1:52 am) · 4 replies
I get a "Register object failed for object flag of type Static...?" error when trying to create a second object, in this case a flag.Im assuming that this is either a:
1) reference issue.(trying to reference the same object twice), or a
2) hierarchy issue.(I don't quite understand the instantial flow yet)
I am only a couple weeks old here, so the chance of me making a stupid mistake is high. The code is called when I hit a button (t) and it spawns a flag on the ground. The functionality seems to work well, but only for the first object. All subsequent attempts to place a flag fail, untill the first flag is deleated. Anyway, here is the code that I have written so far:
Any help in this matter would be great. Thanx for the help guys.
1) reference issue.(trying to reference the same object twice), or a
2) hierarchy issue.(I don't quite understand the instantial flow yet)
I am only a couple weeks old here, so the chance of me making a stupid mistake is high. The code is called when I hit a button (t) and it spawns a flag on the ground. The functionality seems to work well, but only for the first object. All subsequent attempts to place a flag fail, untill the first flag is deleated. Anyway, here is the code that I have written so far:
function serverCmdinteract(%client)
{
//get player position
%player = %client.player;
%eye = %player.getEyeVector();
%vec = vectorScale(%eye, 400);
%startPoint = %player.getEyeTransform();
%endPoint = VectorAdd(%startPoint,%vec);
%searchMasks = $TypeMasks::TerrainObjectType;
//cast ray
%object = ContainerRayCast(%startPoint,%endPoint,%searchMasks, %player);
if(%object)
{
//get surface coords
echo(">object created>>" @ %x);
echo(">object created>>" @ %y);
echo(">object created>>" @ %z);
%item = new StaticShape(Flag)
{
position = localclientconnection.camera.getPosition();
rotation = "1 0 0 0";
datablock = Flag;
};
}
//set object at coordinates
%item.setTransform(%x SPC %y SPC %z);
}Any help in this matter would be great. Thanx for the help guys.
#2
You are a lot of help, thanx.
01/24/2004 (2:31 am)
Thank you james. I see what I am doing now that you have shed some light on my problem. I must be making multiple copies of objects under the same name which is not allowed. You are a lot of help, thanx.
#3
I am not seeing where the %x,y and z are being set
also this would seem to fail as well
01/24/2004 (6:08 am)
Does this spit out what you are expecting?//get surface coords
echo(">object created>>" @ %x);
echo(">object created>>" @ %y);
echo(">object created>>" @ %z);I am not seeing where the %x,y and z are being set
also this would seem to fail as well
%item.setTransform(%x SPC %y SPC %z);
#4
James suggestion A) is what I went with and it works like a charm.
Thank you for your response though Ron, I am always surprised by the helping nature of the members(and associates) here at garage games. Without you guys I would be feeling in the dark.
01/25/2004 (3:58 pm)
Yeah Ron, It does work. I figured out what was happening. I was giving my new object a name when creating it. Since I am using multiple versions of the same block It would crash when I tried to name an object by the same name. James suggestion A) is what I went with and it works like a charm.
Thank you for your response though Ron, I am always surprised by the helping nature of the members(and associates) here at garage games. Without you guys I would be feeling in the dark.
Associate James Urquhart
Either :
A) Use a blank name for the StaticShape, aka
%item = new StaticShape("")B) Have some sort of counter to make unique object names, e.g
%item = new StaticShape("Flag" @ %counter)Hope that helps :)