getting an object to reload
by rennie moffat · in Torque Game Builder · 02/03/2010 (4:08 pm) · 2 replies
Hi there,
I am trying to create a starRejenerator ( I know I spelt generator, with a J) anyhow, point is I have a behavior, where by if starsStar is not in its oringal load pos the behavior owner loads a new star, replacing the old one which has been moved. I have done this code, but it does not work. Can some one help me to figure out this issue?
Cheers, thank you,
Ren.
I am trying to create a starRejenerator ( I know I spelt generator, with a J) anyhow, point is I have a behavior, where by if starsStar is not in its oringal load pos the behavior owner loads a new star, replacing the old one which has been moved. I have done this code, but it does not work. Can some one help me to figure out this issue?
Cheers, thank you,
Ren.
if(!isObject(starRejenerator))
{
%template = new BehaviorTemplate(starRejenerator);
%template.friendlyName = "star rejenerator";
%template.description = "adds new star to scene when one is dropped";
%template.behaviorType = "AI";
%template.addBehaviorField(starsStar, "object behavior must clone", object, "", t2dSceneObject);
}
function starRenjenerator::onBehaviorAdd(%this)
{
%this.owner.enableUpdateCallback();
}
function starRejenerator::onUpdate(%this)
{
%this.starLoader();
}
function starRejenerator::starLoader(%this)
{
if(!isObject(%this.starsStar))
return;
///i figure if I clone with behaviors, i will generate a new star if criteria met
%starsStar = %this.starsStar.cloneWithBehaviors();
%starsStarPos = %this.starsStar.getPosition();
///this is where the starsStar is loaded, if a starsStar is not in this pos a new one must load
%loadPos = %this.owner.getPosition();
if(%starsStarPos == %loadPos)
return;
if(%starsStarPos != %loadPos)
%starsStar.setPosition(%loadPos);
}About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
thanks.
02/03/2010 (5:10 pm)
Hi there, so I have determined I need to cancel the starLoader function, which is slave to onUpdate() if a star is loaded. I have tried many things including, placing a new function call at the end of the starLoader function, then replacing it at the top, essentially saying is a star is loaded, load no more. but it did not work. Please if you have any insight into this, please let me know.thanks.
function starRejenerator::onUpdate(%this)
{
%this.starLoader();
}
function starRejenerator::starLoader(%this)
{
if(!isObject(%this.starsStar))
return;
%starsStarPos = %this.starsStar.getPosition();
%loadPos = %this.owner.getPosition();
if(%starsStarPos == %loadPos)
if(%starsStarPos != %loadPos)
%starsStar = %this.starsStar.cloneWithBehaviors();
%starsStar.setPosition(%this.owner.getPosition());
}
Torque Owner rennie moffat
Renman3000
so it is working,
now there is a major computation as it seems to be infinitely loading a new starsStar, the game is so over whelmed it essentially has frozen. Time for some tinkering.