XNA Creators Club Online
foros de la comunidad
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Spaceship sight

Last post 05/07/2009 20:01 by Skygaz. 2 replies.
  • 29/06/2009 23:41

    Spaceship sight

    Hi all, I'm trying to develop a small spaceship game. I have a third person camera. To help the player to aim I need to put a sight in front of it. How can I do? Where I have to put the sight? Because if I take  the orientation of the spaceship (a quaternion) and transform the Vector3.UnitZ it seem to me to be wrong... (where I shoot is not where I'm aiming).

    ps: the projectile is created on the spaceship position and take the ship direction.

    Thanks
  • 02/07/2009 20:59 In reply to

    Re: Spaceship sight

    This may not be the best way, but this seems like a reasonable solution...

    // get a rotation matrix from the quaternion
    Matrix matrix = Matrix.CreateFromQuaternion(shipOrientation);

    // use the forward vector from the matrix to determine the direction the ship is facing
    // this vector should already be normalized
    Vector3 shipDirection = matrix.Forward;

    // if you want to draw something 100 units out from the ship you can find the point using the direction vector
    aimPosition = shipDirection * 100.0f;


    Now draw your aiming sight at aimPosition.
    Guardian is in playtest

    Blog | Willow Ridge
  • 05/07/2009 20:01 In reply to

    Re: Spaceship sight

    Dave Carlile:
    This may not be the best way, but this seems like a reasonable solution...

    // get a rotation matrix from the quaternion
    Matrix matrix = Matrix.CreateFromQuaternion(shipOrientation);

    // use the forward vector from the matrix to determine the direction the ship is facing
    // this vector should already be normalized
    Vector3 shipDirection = matrix.Forward;

    // if you want to draw something 100 units out from the ship you can find the point using the direction vector
    aimPosition = shipDirection * 100.0f;


    Now draw your aiming sight at aimPosition.


    Thanks for the answer :D
Page 1 of 1 (3 items) Previous Next