How to get object in-front of other object?
<p>Game programming is where I get killed due to not having a strong background in math. As such, I was wondering how I might be able to find an object (Car) in front of another object (Car) using details from this struct.</p>

<pre><code>class CompCar extends Struct // Car info in 28 bytes - there is an array of these in the MCI (below)
{
    const PACK = 'vvCCCxlllvvvs';
    const UNPACK = 'vNode/vLap/CPLID/CPosition/CInfo/CSp3/lX/lY/lZ/vSpeed/vDirection/vHeading/sAngVel';

    public $Node;                       # current path node
    public $Lap;                        # current lap
    public $PLID;                       # player's unique id
    public $Position;                   # current race position : 0 = unknown, 1 = leader, etc...
    public $Info;                       # flags and other info - see below
    protected $Sp3;
    public $X;                          # X map (65536 = 1 metre)
    public $Y;                          # Y map (65536 = 1 metre)
    public $Z;                          # Z alt (65536 = 1 metre)
    public $Speed;                      # speed (32768 = 100 m/s)
    public $Direction;                  # car's motion if Speed &gt; 0 : 0 = world y direction, 32768 = 180 deg
    public $Heading;                    # direction of forward axis : 0 = world y direction, 32768 = 180 deg
    public $AngVel;                     # signed, rate of change of heading : (16384 = 360 deg/s)
};
</code></pre>

<p><code>$Heading</code> and <code>$Direction</code> I can imagine being the most important to getting who is in front of the car. Let's say I want to know who is in front of this object, for the distance of <code>$Speed * 5</code>. I would do that by searching through an array of these CompCar objects, but how do I do that? How do I know that one object is in-front of the other?</p>

<p>To get information about the track, we can use the path file, know by it's extension pth. I've made a <a href="https://github.com/Dygear/PRISM/blob/master/modules/prism_pth.php" rel="nofollow">pth file parser here</a> that can be used to find information about the track. This is where the <code>$Node</code> part of the CompCar becomes useful as we can use that as a point of reference.</p>
