Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7721409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:55:02+00:00 2026-06-01T03:55:02+00:00

Hi, I am making a first person shooter in directX 10 using c++. I

  • 0

Hi, I am making a first person shooter in directX 10 using c++.

I would post my code for help, because I know this is standard practice here, but it is simply too much to put on here. Anyway I don’t know if i’ll be able to get what I’ve got working as the bullets are just going in stupid directions starting from next to the gun.

My question here is, does anyone know how to just make a bullet move towards crosshairs?

I have crosshairs in front of the gun (there actually just cube objects in the shape of crosshairs).

Does anyone know a way in directX10 using c++ to make something just move towards a point at a given speed because surely I can just make my bullets move towards the crosshair and then not have to worry about the code I have at the moment which basically is determining which way the gun is facing and coming out at that angle (which it isnt working properly at all).

I figure if there is a way of making the bullet move towards a specific point then that’s far easier than what I’m doing now.

I know this wasn’t particularly clear, but any help would be much appriciated as I am properly stuck on this.

Here’s the function for bullet direction:

void BDirection(float speed){

float frameTime = 0.01;
initVecDir.x = 0;
initVecDir.y = 0;
initVecDir.z = 1;

D3DXVec3TransformCoord(&newVecDir, &initVecDir, &matAllRotations2);
D3DXVec3Normalize(&currentVecDir, &newVecDir);
float adjustedSpeed = speed*frameTime;

for (int i =0; i<CountB; i++){
BULLETS[i].initVec.x +=  currentVecDir.x*adjustedSpeed;  BULLETS[i].initVec.y +=  currentVecDir.y*adjustedSpeed;
BULLETS[i].initVec.z +=  currentVecDir.z*adjustedSpeed;
}
}

bullet render:

    for(int i =0; i< CountB; i++){

        D3DXMatrixRotationX( &matBulletRotX, BULLETS[i].RotVec.x);
        D3DXMatrixRotationY( &matBulletRotY, BULLETS[i].RotVec.y);
        D3DXMatrixRotationZ( &matBulletRotZ, BULLETS[i].RotVec.z);
        D3DXMatrixScaling(&matScale2, 1,1,1);
        D3DXMatrixTranslation (&matTranslate2, BULLETS[i].initVec.x,  BULLETS[i].initVec.y, BULLETS[i].initVec.z);
        matAllRotations2 = matBulletRotX * matBulletRotY * matBulletRotZ;
        matBulletWorld =  matAllRotations2 * matScale2 * matTranslate2;         

        mWorldViewProjection = matBulletWorld * mView * mProj;

        // Update the effect's variables. 
        V( g_pWorldViewProjection->SetMatrix( (float*)&mWorldViewProjection ) );
        V( g_pWorld->SetMatrix( (float*)&matBulletWorld ) );
        V( g_pTime->SetFloat( (float)fTime ) );
        V( g_pCameraPosition->SetFloatVector( (float*)g_Camera.GetEyePt() ) );   

        for ( UINT iSubset = 0; iSubset < BULLETS[i].bullet.GetNumSubsets(); ++iSubset )
        {
            RenderSubset2( iSubset, i );
        }
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:55:04+00:00Added an answer on June 1, 2026 at 3:55 am

    You need to determine the vector that the user is looking at, depending on what type camera you used, this would be the look-at vector. This becomes the velocity of the object. You also need to rotate the object to match this if it can be seen.

    If you are having the bullets originate from the gun itself, you need to determine where the cross-hairs actually point at to compensate for the difference between what the users sees and where the bullet will end up. I would suggest looking at the “Pick” sample from the DirectX SDK.

    [Edit] I rewrote it after reading you question again, sorry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I apologize for making my first question not the hard-hitting code-related question I was
I'm working on a FPS (first person shooter) game at the moment, I want
I am making a kind of first person game but my view seems to
First a few definitions to keep things clear. User: A live person, using the
I'm making my first iphone application and it's a wine chart application. It's with
I am making my first android app. I want to save an array of
I am making my first android application, and it requires switching between activities very
I am making my first major iPhone app and need some advice in saving
I am making my first text field, and I am looking for more of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.