Game Development Community

Template Behavior SUCKS

by Nicolai Dutka · in Torque Game Builder · 04/08/2008 (11:58 am) · 3 replies

Here is the description of the template behavior:

"Disables an object unless it is a clone"

So why is my object WITH a template behavior SHOOTING other templates off-screen? The clones work beautifully, but the template is NOT supposed to be able to shoot!

Why is my template object deleting?? The world limits are set to KILL and it IS outside its limits, but again, it's SUPPOSED ot be a template object! I don't want ANY of the rules to apply to it. THIS SUCKS! Now my templates need to be inside the world limits too! :(

#1
04/08/2008 (12:39 pm)
It's been a few months(and versions) since I've played with TGB, so forgive me if I'm a little rusty here. I remember running into the same problem.

First things first, as I remember it the template objects do need to reside within the world limits, especially if there are world limits set on them.

Now the shooting part, that happened as well I believe. Unfortunately I can't remember of the top of my head what the problem was. I'll have to check that project when I get home. I seem to think that I either set up the template wrong, or wasn't spawning the clones yet.
#2
04/08/2008 (12:43 pm)
I've already got it all fixed, I just thought this was a crappy limitation worth mentioning...

For the shooting, I took the "timer shoots" behavior off and have it added on to the clone on creation instead. Works great and here's the code I used to do it in case anyone is looking at this and wondering:

%shoot = TimerShootsBehavior.createInstance();
    %shoot.projectile="shot3";
    %shoot.fireRate=0.500 + (0.1*$level);
    %shoot.fireRateVariance=0.200 + (0.05*$level);
    %shoot.projectileSpeed= 70 + (5 * $level);
    $boss.addBehavior(%shoot);
    $boss.fire();
#3
04/08/2008 (1:21 pm)
I think you might have the wrong impression of what the template behavior is supposed to do.

All it does is simply disable the object when the level is loaded. This means that any clones will still have the template behavior attached to it (if cloneWithBehaviors() is used) but since the level is already loaded, they will not be disabled.

The reason the shooting is still occuring is because the behavior instance calls a fire schedule when it is added to the scene. All you have to do there is delete the schedule and the template object won't fire. You will have to call the fire function separately for all clones though.

I know you'd rather not have the rules be applied to it, but then it sort of defeats the purpose of creating a template object within the editor. You'd be better off setting object properties directly in script like you did with the shoots behavior.