Game Development Community

Deleting object if it goes beyond world limit

by Corey Magin · in Torque Game Builder · 02/01/2008 (10:55 am) · 3 replies

Hi,

I'm trying to limit bullets fired to stay within world limit bounds that I set.

here is what I've got but bullets still go outside their bounds.

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

%template.friendlyName = "bulletWorldLimit";
%template.behaviorType = "Effects";
%template.description = "destroy self when the object hits its world limit";
}

function bulletWorldLimit::onBehaviorAdd(%this)
{
%this.owner.worldLimitCallback = true;
}

function bulletWorldLimit::onWorldLimit(%this, %limitMode, %limit)
{
switch$ (%limit)
{
case "left":
%this.safeDelete();

case "right":
%this.safeDelete();

case "top":
%this.safeDelete();

case "bottom":
%this.safeDelete();
}
}

What's wrong with this?

#1
02/01/2008 (10:58 am)
%this.owner.safeDelete(); instead of %this.safeDelete() should do the trick.
#2
02/01/2008 (11:05 am)
Ok I feel smart. this doesn't need a custom function. Just have to set limit mode to kill. yikes.
#3
02/01/2008 (11:05 am)
Thanks Alex this is good to know.