Expected behavior for setWorldLimit callback?
by Ben Shive · in Torque Game Builder · 05/24/2005 (3:23 am) · 6 replies
I'm setting it up as follows:
%randball.setWorldLimit( CLAMP, "-400 -300 400 300", true );
The object collides with the world limit, gets clamped to the strike point just fine. However, I get 5-12 calls to onWorldLimit. It's easily worked around by checking to see if you've already done the collision once, but I was wondering if this behavior is expected. it just seems odd to me that it's not even a consistent number of calls to the function, even though the objects currently all have the same linear velocity.
%randball.setWorldLimit( CLAMP, "-400 -300 400 300", true );
The object collides with the world limit, gets clamped to the strike point just fine. However, I get 5-12 calls to onWorldLimit. It's easily worked around by checking to see if you've already done the collision once, but I was wondering if this behavior is expected. it just seems odd to me that it's not even a consistent number of calls to the function, even though the objects currently all have the same linear velocity.
#2
05/24/2005 (8:36 am)
Thanks Brian, I didn't catch the mention of this getting fixed in v1.0.2. Setting the relaxation to 1 worked for me, so I can eliminate that one check.
#3
I know this does work unless you've found some bizarre problem.
- Melv.
05/24/2005 (11:58 am)
This was fixed in v1.0.2 and I've not seen it happen since. Setting the relaxation to 1 is a very bad way to fix this problem as it just means that all the collisions with objects will be incorrect, causing a severe jump-back upon collision.I know this does work unless you've found some bizarre problem.
- Melv.
#4
Maybe I should have said 'a (temporary) workaround'. ;-)
My current project doesn't use the physics (yet), other than onWorldLimit() which explains why I don't see any problems!
05/24/2005 (2:29 pm)
Quote:For earlier versions, IIRC, the workaround was to set the objects relaxation to 1.
Maybe I should have said 'a (temporary) workaround'. ;-)
My current project doesn't use the physics (yet), other than onWorldLimit() which explains why I don't see any problems!
#5
Thanks for the replies guys.
05/24/2005 (6:41 pm)
Updated to v1.0.2 and no problems with the multiple calls from worldlimit, now to figure out why I get 1-2 pixel variation in distances on object collision. Thanks for the replies guys.
#6
Here's the code:
Player Init:
Using setRelaxation doesn't seem to help any either. As you can see, I've tried turning off collisions on the player object as soon as it hits the bottom wall, but no joy. I've also tried setAtRest.
Any hints?
++
Edit: OK, so I've replaced my .exe with the one from the T2D example, and it seems to be OK. Time to go through the source code and possibly buld myself a new one...
09/20/2005 (3:47 pm)
I've just gotten around to wanting to do stuff based around onWorldLimit, and I'm having problems similar to those listed above.Here's the code:
Player Init:
function initPlayer()
{
// define player
$player = new fxAnimatedSprite2D() { scenegraph = t2dSceneGraph; };
$player.setPosition("0 0");
$player.setSize( "10 5" );
$player.playAnimation( helicopterAnimation );
$player.setGroup(1);
$player.setLayer(15);
$player.setCollisionPolyPrimitive(4);
$player.setCollisionScale("1 0.62");
$player.setCollisionActive( true, false );
$player.setCollisionMasks( BIT(3)|BIT(2), BIT(5)|BIT(10) );
$player.setCollisionCallback( true );
$player.setWorldLimit( CLAMP, "-48 -36 48 28", true );
$player.tag = "player";
$player.speed = 10;
$player.hascargo = false;
$player.score = 0;
}Callback:function fxSceneObject2D::onWorldLimit(%this, %limitMode, %wall)
{
if (%this.tag $= "player" && %wall $= "bottom")
{
echo("crash");
$player.setcollisionsuppress (true);
explodeTarget($player);
}
}Console log:crash crash crash crash crash crash crash crash crash crash crash crash crash crash crash crash crash
Using setRelaxation doesn't seem to help any either. As you can see, I've tried turning off collisions on the player object as soon as it hits the bottom wall, but no joy. I've also tried setAtRest.
Any hints?
++
Edit: OK, so I've replaced my .exe with the one from the T2D example, and it seems to be OK. Time to go through the source code and possibly buld myself a new one...
Torque Owner Brian Painter
Scrith Productions
For earlier versions, IIRC, the workaround was to set the objects relaxation to 1.
e.g. % randball.setRelaxation( 1 );
I'm still using v1.0 and this works fine for me, although I'm not using the CLAMP option, just the callback.
Bri