RC3 - onPositionTarget Callback Missed Sometimes.
by Rodney Rindels - Torqued · in Torque Game Builder · 06/18/2006 (8:02 pm) · 11 replies
Drop a sprite on your level, name it whatever but give it class name Sprites
start your level, then get the little guy flinging around the screen with the following code..
in console: mysprite.moveToRandom();
every so often, sometimes at 10 simulations , sometimes at 10K , he will totally blow the onPositionTarget() callback..
which because it can happen anytime, it seems to me this needs to be looked into.
In my domino simulation I can run 10 games fine, then in another game it just misses totally..
Thanks for looking into it.
The more sprites you have and of course the faster you run it, the sooner you'll notice the issue ...
start your level, then get the little guy flinging around the screen with the following code..
in console: mysprite.moveToRandom();
function Sprites::moveToRandom(%this)
{
$simulation++;
%x = getRandom(-50,50);
%y = getRandom(-30,30);
%this.rotateTo(getRandom(360),1000);
%this.moveTo(%x SPC %y,1000,true,true,true,0);
}
function Sprites::onPositionTarget(%this)
{
%this.moveToRandom();
}every so often, sometimes at 10 simulations , sometimes at 10K , he will totally blow the onPositionTarget() callback..
which because it can happen anytime, it seems to me this needs to be looked into.
In my domino simulation I can run 10 games fine, then in another game it just misses totally..
Thanks for looking into it.
The more sprites you have and of course the faster you run it, the sooner you'll notice the issue ...
#2
its not enough to just let it run a few thousand times, sometimes it takes upward of 40K iterations to misfire. Hence why I haven't been able to trap why?
but like I said sometimes you'll hit it in the first 100 or so iterations.
06/18/2006 (9:00 pm)
Nope out of the box. RC3 install tested for reproduction of the issue, new project, nothing else even there except for your demos. no c++ touched, etcits not enough to just let it run a few thousand times, sometimes it takes upward of 40K iterations to misfire. Hence why I haven't been able to trap why?
but like I said sometimes you'll hit it in the first 100 or so iterations.
#3
06/19/2006 (12:11 am)
You're moving quite fast with a margin of 0. Does it still miss if you either slow the object down or increase the margin a little?
#4
06/19/2006 (12:17 am)
Yeah I realize that i'm moving quite fast, I sped it up for the purpose of getting the problem to show sooner , my original simulation speeds were 200, margin 0, maybe its just a margin issue, but with nothing colliding, and a moveTo being a specific world Coordinate, I can't imagine the object not being able to get there with that accuracy all the time. I'll try messing with the margins a bit and see if it still occurs with a little margin help, and I'll slow it back down and run another 50K or so simulations. I'll let you know the results.
#5
All checks like this should have a programmed threshold of error that handles your simulation parameters and gives the look/feel you want--and 0 tolerance isn't going to be consistent.
06/19/2006 (2:04 pm)
Margin checking is critical here---0 is pretty impossible to guarantee hitting consistently. I'm actually surprised it's taking so long to duplicate the miss given your parameters.All checks like this should have a programmed threshold of error that handles your simulation parameters and gives the look/feel you want--and 0 tolerance isn't going to be consistent.
#6
I hope its not as ugly as having to track positions in onUpdateScene callbacks.. ewwww
In my simulation, I "absolutely" have to know the object reached its setPositionTarget to start the next objects actions. If any one object in the chain doesn't reach the intented positions, my simulation basically stops, and in a few cases the simulation object continues off screen.
I dont need physics or anything enabled, does it increase the accuracy removing any objects settings? I just need rotateTo and moveTo for my objects. I dont need collisions, physics, etc..
06/19/2006 (2:22 pm)
It was just unusual since it did run at such high velocity for so long I suppose, it looked like an error when it didn't fire the callback, adjusting the margins definitely makes the simulation more accurate, but in absence of being able to guarantee a callback of 100% is there any idea about how to keep position state? There isn't an object missed callback to trap when objects miss the position, so how can one use setPositionTarget at any level of accuracy? I hope its not as ugly as having to track positions in onUpdateScene callbacks.. ewwww
In my simulation, I "absolutely" have to know the object reached its setPositionTarget to start the next objects actions. If any one object in the chain doesn't reach the intented positions, my simulation basically stops, and in a few cases the simulation object continues off screen.
I dont need physics or anything enabled, does it increase the accuracy removing any objects settings? I just need rotateTo and moveTo for my objects. I dont need collisions, physics, etc..
#7
Worst case, it could provide your 'second level of guarantee' in a relatively easy manner.
06/19/2006 (2:29 pm)
How about creating actual sceneObjects instead of using mathematical points in space? That way you can track that a point has been "hit" by an onCollision callback, and handle things that way--and have a built in (and visual) threshold to adjust rather easily.Worst case, it could provide your 'second level of guarantee' in a relatively easy manner.
#8
06/19/2006 (2:34 pm)
Thanks Stephen, I'll adjust and attempt somethings more "visual" I suppose . I was trying to get away from having to build collision areas or triggers surrounding these points in space. Thanks anyway, sorry about the bug report, the tool just worked too damn good for too many iterations :-)
#9
06/19/2006 (2:35 pm)
Shouldn't this be caught be mathematical means instead of relying on a high update rate? Like not check if the objects position is within the margin every frame but if the line the object moved between this frame and the last intersect within the margin circle. This should be rather fool-proof.
#10
06/19/2006 (3:21 pm)
@Rodney: I'm not saying this is a solution--mostly because I don't know exactly what your problem is (other than missing your point(s))--but in general you must provide a threshold of error when trying to move to a particular point...it's just impossible to hit exactly zero tolerance movement based on a velocity over time type of move scenario.
#11
06/19/2006 (3:33 pm)
Well it was a fairly trivial simulation just moving a set of 30 objects to specific vectors, when the first object reaches its setTargetPosition, the second fires and so on and so forth until all objects are in position. No object was moving faster than moveTo velocity of 100 which moving that slow I thought could never miss, guess I know better now. I have a strategy that might determine effective in other places in my simulation to double check the accuracy of the callback. I really appreciate you guys taking the time to respond..
Torque 3D Owner Matthew Langley
Torque