realbasic-games
[Top] [All Lists]

Re: 3D Ball

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: 3D Ball
From: Lars Jensen <larsjensen at rcn dot com>
Date: Mon, 26 Sep 2005 15:52:37 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
> OK, well this is pretty easy -- if you look down on the scene from
> above, both the ball and the houses are circles.  So to see whether
> the ball has hit a house, just find the distance between the ball
> center and the house center.  If this distance is less than the sum
> of their radii, it has hit, otherwise not.

That technique is easy but incomplete: if the ball is moving fast, then it
might intersect the other object in the middle of a frame. So you might need
to find the point of intersection, otherwise the ball will stop before it
appears to hit the house, or after it has penetrated it to some degree. If
the ball is moving really fast, it might even appear to go right through the
house; i.e. you might miss the collision entirely.

The slower the ball goes, the less of an issue this is. Or if you have many
balls flying around, then maybe the user is unlikely to notice this type of
thing. But if it ends up being a problem for you, the sphere-sphere
collision article I posted earlier shows how to handle it.

lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>