Game Development Community

Need a bit of help in the mounting department... -Solved

by Michael Kantack · in Torque Game Builder · 06/30/2008 (11:12 am) · 8 replies

So, I'm trying to generate limbs for creatures in-game; as opposed to placing them by hand. I have link points set up on said creatures in the engine; and a behavior added to them that should generate and add limbs. The problem is, several days of headaches and research later I am unable to solve the problem of mounting in script.

in my behavior I have this:

function AddLimbBehavior::onAddToScene(%this, %scenegraph)
{

%limb = new t2dStaticSprite() {
scenegraph = t2dSceneGraph;
imageMap = "armImageMap";
};

%limb.mount(%this.owner, %this.xMount, %this.yMount, %this.mountForce, false, true, false, false);

}

I've run a plethora of echo tests in a vain attempt to figure out where i've gone wrong. No matter what I change, all I manage to get done is switching the error message the console outputs...

While I'm not new to coding or scripting... I am new to this particular flavor. If someone could aid me, I would be very grateful. Thanks much,

3li


-EDIT- I've also tried this in onAddBehavior to no avail. I'm starting to think I don't know how to dynamically mount OR how to generate a static sprite, as I can successfully do neither.

-EDIT- Okay, here's the new code...

function AddLimbBehavior::onBehaviorAdd(%this)
{
new t2dImageMapDatablock(armImageMap)
{
imageMode = "full";
imageName = "~/data/images/arm.png";
};

%this.limb = new t2dStaticSprite()
{
sceneGraph = %this.scenegraph;
};

%this.limb.setImageMap(armImageMap);
%this.limb.setVisible(true);
%this.limb.mount(%this, "0 0", 0, false, true, false, false);


}

Which outputs, "couldn't find/invalid object"... I obviously need some help here... haha.

#1
06/30/2008 (5:12 pm)
Also, if this should be somewhere else, I apologize.

-EDIT- Heres yet another failed attempt...

if (!isObject(AddLimbBehavior))
{
%template = new BehaviorTemplate(AddLimbBehavior);

%template.friendlyName = "Add Limb";
%template.behaviorType = "Procedural";
%template.description = "Adds (a) random limb(s)";
}

function AddLimbBehavior::onBehaviorAdd(%this)
{

%imgMap = armImageMap;
%limb = new t2DStaticSprite()
{ sceneGraph = $SceneGraph;
imageMap= %imgMap; CollisionResponseMode = "RIGID";
CollisionActiveSend = "1"; CollisionCircleScale = ".2";
CollisionLayers = "-1"; CollisionPhysicsSend = "1";
};
%limb.mount(%this, "0 0", 0, false, true, true, true);

}


that's the full code for the behavior
Still getting same error. I'm at this point not familiar enough with this to figure out if the limb is even being created although the invalid object error is leading me to believe it's not.
#2
06/30/2008 (9:15 pm)
Hmm, maybe your not setting your sceneGraph correctly? Have you tried this:
sceneWindow2d.getSceneGraph();


as in:
function AddLimbBehavior::onBehaviorAdd(%this)
{

%imgMap = armImageMap;
%limb = new t2DStaticSprite()
{ sceneGraph = sceneWindow2d.getSceneGraph();
imageMap= %imgMap; CollisionResponseMode = "RIGID";
CollisionActiveSend = "1"; CollisionCircleScale = ".2";
CollisionLayers = "-1"; CollisionPhysicsSend = "1";
};
%limb.mount(%this, "0 0", 0, false, true, true, true);

}

one of you torque guru's can tell me if I'm wrong.. but give it a try. You need to make sure the sprite is showing up first of course.. before you can mount it anywhere ;D.
#3
07/01/2008 (11:03 am)
Okay, thanks to you I can now generate the object successfully; it shows up on my debug banner as well in the actual playing field of my game! One half the way there as it were. The only problem is when I try to mount it, it still produces the same error. Here is the new, mostly functioning code...

if (!isObject(AddLimbBehavior))
{
   %template = new BehaviorTemplate(AddLimbBehavior);
   
   %template.friendlyName = "Add Limb";
   %template.behaviorType = "Procedural";
   %template.description  = "Adds a random limb(s)";
}


function AddLimbBehavior::onBehaviorAdd(%this)
{

    %limb = new t2DStaticSprite()
           { sceneGraph = sceneWindow2d.getSceneGraph();
             CollisionResponseMode = "RIGID";
             CollisionActiveSend = "0"; CollisionCircleScale = ".2";
             CollisionLayers = "-1"; CollisionPhysicsSend = "0";
	    };
			
	
	new t2dImageMapDatablock(armImageMap)
	{
   		imageMode = "full";
   		imageName = "~/data/images/arm.png";
	};
	
	
	%limb.setImageMap(armImageMap);
	%limb.setSize(2.6,10);
	%limb.setVisible(true);
	%limb.setPosition(4,11);
	%limb.mount(%this.owner, "0 0", 0, false, true, true, true);
}

I'm wondering if it's trying to mount it before it finishes creating it, so I'm going to try scheduling it. If that doesn't work then I'm at a loss again.

Thanks for the help, it's almost there!

-EDIT- just figured out the whole /code thing... apologies all around for that one!
#4
07/01/2008 (11:13 am)
Just wanted to point out that after figuring out that first part, scheduling was in fact the issue! Thanks so much Nic!
#5
07/01/2008 (11:25 am)
Good job.
Now you have me curios.. sounds like a pretty neat game your working on. I love games with original gameplay. Can you give me a hint about what the game is?
#6
07/01/2008 (11:36 am)
I can indeed. First off, it should be available for purchase within a two week time-span baring any particular mis-haps. Secondly, the few people who've played the demo build have described it to me as one of the most disturbing games they've seen in quite some time.

The trick here is the setting, theme, and style.

It's a short but sweet platforming adventure based around 14 chapters of a small strange world i've created. The real point is to make each second as memorable as possible. I'm not really basing it around any target market so it should be a product of my imagination and no one else's.

If after this seemingly bland info you are still interested I'll point the first info my press man leaks your way.
#7
07/01/2008 (11:40 am)
Also, can I just say I love the feel of your project. Feels very... free. I've no idea how large the environs your game will feature; but if they are even medium sized I would have fun just bopping around in them.
#8
07/01/2008 (12:09 pm)
Sounds neat. I'm looking forward to playing the demo!
-nic