quick help suggestion
by rennie moffat · in Torque Game Builder · 04/21/2010 (8:25 am) · 7 replies
Hi Could somebody give me some quick help/suggestion?
I have been running this all morning, it worked coiuntless times before but not now. I simply am getting an objects, well 2's position, but there is no return in the echo. Very odd as I have behaviors with 30 objects let alone two. I need no programming help, maybe stratigical. I am not sure but this, as follows, does not return anything?! what they hey.
I have been running this all morning, it worked coiuntless times before but not now. I simply am getting an objects, well 2's position, but there is no return in the echo. Very odd as I have behaviors with 30 objects let alone two. I need no programming help, maybe stratigical. I am not sure but this, as follows, does not return anything?! what they hey.
//////
//%template.addBehaviorField(node1, "", object, "", t2dSceneObject);
//%template.addBehaviorField(node2, "", object, "", t2dSceneObject);
/////
function bigBlueBehavior::onBehaviorAdd(%this)
{
%this.node1Pos = %this.node1.getPosition();
%this.node2Pos = %this.node2.getPosition();
%this.owner.enableUpdateCallback();
}
function bigBlueBehavior::onUpdate(%this)
{
%this.bigBluePos = %this.owner.getPosition();
echo("bigBlueBehavior::onUpdate");
echo(" %this.bigBluePos " @ %this.bigBluePos);
echo(" %this.node1Pos " @ %this.node1Pos);
echo(" %this.node2Pos " @ %this.node2Pos);
}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
If your not getting the echo, the logic is not getting there. Your onUpdate callback is not getting fired. I don't know why onUpdate gets fired for some objects but not others or why it works for awhile and then stops. That's a mystery for which I'm looking for the answer as well.
04/21/2010 (8:50 am)
When you say "no return in the echo" I assume you mean the echo result does not show up in the console...If your not getting the echo, the logic is not getting there. Your onUpdate callback is not getting fired. I don't know why onUpdate gets fired for some objects but not others or why it works for awhile and then stops. That's a mystery for which I'm looking for the answer as well.
#3
I have bumped into something interesting this morning too. And it may relate to some to other issues I was having. But.... I had a behavior, it would set an object to layer 0, then on schedule to 31, then on schedule back to 0 and so on. I changed the behavior to do this to 3 objects instead of one. After I had completed the adding in of the new behavior I simply moved the original object out of the way and, did not delete it. But it was no longer named as a behavior field. Just an object in space i presumed. Anyhow, my new behavior would not work until i deleted this "old object". Upon deleting it, just before I threw my computer out the window, this triggered the behavior to work.
Why is it that an object, which was formerly tied to a behavior, would it's presence disturb the functionality of the "new behavior" it is no longer a part of? Id this logical? it does not sound like it. But again... ghosts in the machine?
04/21/2010 (9:25 am)
ok, thanks Kevin (side note. James is my middle name). what you say makes sense. I have bumped into something interesting this morning too. And it may relate to some to other issues I was having. But.... I had a behavior, it would set an object to layer 0, then on schedule to 31, then on schedule back to 0 and so on. I changed the behavior to do this to 3 objects instead of one. After I had completed the adding in of the new behavior I simply moved the original object out of the way and, did not delete it. But it was no longer named as a behavior field. Just an object in space i presumed. Anyhow, my new behavior would not work until i deleted this "old object". Upon deleting it, just before I threw my computer out the window, this triggered the behavior to work.
Why is it that an object, which was formerly tied to a behavior, would it's presence disturb the functionality of the "new behavior" it is no longer a part of? Id this logical? it does not sound like it. But again... ghosts in the machine?
#4
04/21/2010 (11:54 am)
This will happen if your old object has a hard coded name. You copy it into a new object and forget to change the name or delete the name on the old object. In that situation, the system is sending callbacks to the old object while the new one sits there neglected.
#5
04/21/2010 (12:21 pm)
so in theory, if that name, of that object is deleted. it is, in my case rendered null and erasing the name is just as good as deleting it. Correct?
#6
04/21/2010 (12:39 pm)
Exactly. I've made this mistake many times. I copy an object and then pull my hair out trying to figure out why my game suddenly goes haywire. The solution is to delete the old object or rename it.
#7
04/21/2010 (12:46 pm)
yes ok. I thought i was good at that.
Torque Owner rennie moffat
Renman3000
if(!isObject(bigBlueBehavior)) { %template = new behaviorTemplate(bigBlueBehavior); %template.friendlyName = "bigBlueBehavior"; %template.description = "bigBlueBehavior"; %template.behaviorType = "bigBlueBehavior"; %template.addBehaviorField(node1, "", object, "", t2dSceneObject); %template.addBehaviorField(node2, "", object, "", t2dSceneObject); %template.addBehaviorField(velocity, "", float, "10"); %template.addBehaviorField(pauseTime, "", float, "10"); } function bigBlueBehavior::onBehaviorAdd(%this) { %this.node1Pos = %this.node1.getPosition(); %this.node2Pos = %this.node2.getPosition(); %this.owner.enableUpdateCallback(); } function bigBlueBehavior::onUpdate(%this) { %this.bigBluePos = %this.owner.getPosition(); echo("bigBlueBehavior::onUpdate"); echo(" %this.bigBluePos " @ %this.bigBluePos); echo(" %this.node1Pos " @ %this.node1Pos); echo(" %this.node2Pos " @ %this.node2Pos); if(t2dVectorCompare(%this.mouserPos, %this.node1Pos)) { %this.schedule(%this.pauseTime, chooseFromNode1); } if(t2dVectorCompare(%this.mouserPos, %this.node2Pos)) { %this.schedule(%this.pauseTime, chooseFromNode2); } }