Game Development Community

Add Objects Dynamicly to Game

by Paul Kamma · in Torque Game Builder · 08/17/2007 (3:53 pm) · 5 replies

Hi,
I'am new to the TGB.
Played around with the Tutorials a bit and I'am wondering howdo I add objects dynamicly to the scene.
e.g. how di i make a behavior for my fish that spawn bubbles out of the mouth.
Or how Do i spawn other Fishes randomly?

Did I always have to place objects outside of the Camera View and then duplicate it?

Thanx
XT

About the author

Recent Threads


#1
08/17/2007 (4:26 pm)
Hi Paul,

No need to have an object to duplicate - you can do it entirely from script.

%newObject = new t2dAnimatedSprite()
   {
		animationName = "miteAnimation";
		scenegraph = miteWorld;
		layer = 4;
		class = mite;
   };

Any other properties you'd have otherwise set in the level editor (eg collision setting) can be set in the above.

Give your root scenegraph a name in the level builder (miteWorld in the above) - so the start of your .t2d level looks like eg:

%levelContent = new t2dSceneGraph(miteWorld) {

hth :)
#2
08/17/2007 (4:52 pm)
Thanks so Far.
But honestly said .. I dont know where i have to put the thing.
I know the script part (made the tutorials in the trail) but i think i need more practice =o)

What is the "miteAnimation" object?

And where do i have to put the stuff in? =)
#3
08/18/2007 (3:51 pm)
Yes.. this is a big problem for new users to TGB.. there is minimal instruction on how to get started. On first glance, it would appear that you can just drag/drop everythign in the level editor and poof.. a game. But alas not the case.. but the documentation is simply lacking to help you get going in that regard and the only books out on torque are for TGE.. which while the same language.. is still different than a book on TGB. My hope is someone will write a TGB book soon... but still we wait.
#4
08/19/2007 (2:01 am)
Thats also a little hurdle for me to purchase the Engine :o/
#5
08/19/2007 (2:44 am)
Hi Paul, "miteAnimation" in my example is the name of an animation you've already set up in the level editor (ie, it's in the palette on the right, NOT instanced in your level).

I agree that there's a learning curve. Currently in two minds myself. Evaluation continues :D