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?
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?
About the author
Associate Alex Scarborough