Perfect Bounce between two objects with density - Help
by Stefan · in Torque Game Builder · 08/22/2005 (4:22 am) · 8 replies
I'm making a pong-type game just to get to know the engine better, and I'm trying to make the ball bounce against the paddle without losing any velocity.
I've searched the forums, and the only solution I've come up to is to set the paddle's density to 0.
This won't work for me, because if I do, I can't move the paddle.
Is there another way to do this?
Thanks!
..By the way, my collisionMaterial datablocks look like this:
datablock fxCollisionMaterialDatablock2D(ballMaterial)
{
friction = 0;
restitution = 1;
relaxation = 0.5;
density = 0.01;
forceScale = 1;
damping = 0;
};
datablock fxCollisionMaterialDatablock2D(paddleMaterial)
{
friction = 0;
restitution = 0;
relaxation = 0.5;
density = 1;
forceScale = 1;
damping = 0;
};
I've searched the forums, and the only solution I've come up to is to set the paddle's density to 0.
This won't work for me, because if I do, I can't move the paddle.
Is there another way to do this?
Thanks!
..By the way, my collisionMaterial datablocks look like this:
datablock fxCollisionMaterialDatablock2D(ballMaterial)
{
friction = 0;
restitution = 1;
relaxation = 0.5;
density = 0.01;
forceScale = 1;
damping = 0;
};
datablock fxCollisionMaterialDatablock2D(paddleMaterial)
{
friction = 0;
restitution = 0;
relaxation = 0.5;
density = 1;
forceScale = 1;
damping = 0;
};
#2
As far as I know, only the density is checked for the "target" object. (The ball is colliding with the paddle, not the other way around).
It might check relaxation aswell, not sure.
Thanks for your advice, anyway. :)
08/22/2005 (5:49 am)
Setting restitution to 1 for paddles changed nothing.As far as I know, only the density is checked for the "target" object. (The ball is colliding with the paddle, not the other way around).
It might check relaxation aswell, not sure.
Thanks for your advice, anyway. :)
#3
Try that for your balls and then set some walls to imovable. I found a high collision poly count on the ball increases my bounce and lessens the velocity leak. I still get a velocity leak though over time depending on the collisions. Waiting for the upcoming collision modes and eliptical collisions to finish. =)
08/25/2005 (7:01 am)
datablock fxCollisionMaterialDatablock2D(ballMaterial)
{
friction = 0.0;
restitution = 1.0;
relaxation = 0.0;
density = 0.01;
forceScale = 5;
damping = 0.0;
};
datablock fxCollisionMaterialDatablock2D(paddleMaterial)
{
friction = 0.0;
restitution = 0.0;
relaxation = 0.0;
density = 0.01;
forceScale = 5;
damping = 0.0;
};Try that for your balls and then set some walls to imovable. I found a high collision poly count on the ball increases my bounce and lessens the velocity leak. I still get a velocity leak though over time depending on the collisions. Waiting for the upcoming collision modes and eliptical collisions to finish. =)
#4
Thanks for the help anyway, everyone! :)
08/25/2005 (8:45 am)
Yeah, I tried that, but I can't afford any velocity leak at all. I ended up coding my own collision physics, and they work great.Thanks for the help anyway, everyone! :)
#5
08/26/2005 (1:46 am)
I also did that - and it works just fine except that sometime the ball is stuck inside a paddle - but if I move the paddle around the ball eventually falls free...
#6
08/26/2005 (5:46 am)
If you have icq or msn or something, I could give you the code through that, if you need it.
#7
08/26/2005 (5:47 am)
That would be really nice. My ICQ#: 8668131
#8
11/23/2005 (6:10 pm)
Me too please ICQ # 13463220
Torque Owner Johan Stenqvist (neochrome)
I have similar problems (and I'm also working on a sort of pong-style game).
I think if you set restitution for your paddles to 1 the velocity won't bleed off after collisions.
My problems are that the ball bounces in a sometimes *very* unpredictable way - change of direction etc.
I was thinking about writing my own collision response code to just make a perfect bounce and bypass the
physics entirly for now...