Collision between 2 balls
-
Serg Nechaeff
- Posts: 162
- Joined: Wed Nov 26, 2003 5:24 pm
- Location: Europe
Collision between 2 balls
I have 2 balls (3ds models) how can I detect when they touch each other? I have them in 2 different nodes... Thnx in advance!
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
-
Serg Nechaeff
- Posts: 162
- Joined: Wed Nov 26, 2003 5:24 pm
- Location: Europe
Maybe I have to calculate the distance between their centres?
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
-
Serg Nechaeff
- Posts: 162
- Joined: Wed Nov 26, 2003 5:24 pm
- Location: Europe
oh... it sucks! i wanted to finish my game in 2 days, it complicates things a bit... probably will go with radius vectors or smth :-/
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
-
Guest
The solution is sooo simply : Calculate the distance between the centers of your balls. That is dist = ball2_pos - ball1_pos. Add the radius' of the two balls and compare it to the distance. rad = ball1_rad + ball2_rad;
if (dist > rad) --> not colliding
if (dist == rad) --> touching
if (dist < rad) --> intersecting each other
To calculate co-called "dynamic" collision detection, simply advance one frame and test for collision. If they collide, un-do your move ! It's as easy as that...
if (dist > rad) --> not colliding
if (dist == rad) --> touching
if (dist < rad) --> intersecting each other
To calculate co-called "dynamic" collision detection, simply advance one frame and test for collision. If they collide, un-do your move ! It's as easy as that...
-
Serg Nechaeff
- Posts: 162
- Joined: Wed Nov 26, 2003 5:24 pm
- Location: Europe
yeah, thanks, i did that already
another solution is to use bounding box collisions
http://www.javazing.com
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
P-III-950, WinXP, GeForce FX5600 128 MB ForceWare 52.16, DX9, Eclipse IDE, JRE 1.6
-
Isometric God
- Posts: 69
- Joined: Sun Oct 12, 2003 3:42 pm
- Location: Germany