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

  • Home
  • SEARCH
  • 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 7712733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:42:21+00:00 2026-06-01T01:42:21+00:00

Hi i am using DirectX 10 and C++ to make a very simple first

  • 0

Hi i am using DirectX 10 and C++ to make a very simple first person shooter just a gun and targets, i have the gun and the target and the gun shoots bullets in the corrct direction etc.

however i cannot get the camera to be locked on the gun and looking at the crosshairs,
for the camera i have this

vecEye.x = g_f_GunX;
vecEye.y = g_f_GunY + 3;
vecEye.z = g_f_GunZ - 5.0;


vecAt.x = g_f_CrossX;
vecAt.y = g_f_CrossY;
vecAt.z = g_f_CrossZ;

g_Camera.SetViewParams( &vecEye, &vecAt );

for the purpose of this my crosshair is just an object that is infront of the gun and it moves with the gun, i have put the code for the camera in the ‘onFrameRender’ method

it is my assumption that this code should put the camera just behind my gun and when the gun (and crosshairs) are moved the camera should be looking at the crosshairs all the time in the center of the screen, however on running it the camera is not doing this at all and doesnt move with gun or crosshairs at all

any help would be much appriciated

  • 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-01T01:42:22+00:00Added an answer on June 1, 2026 at 1:42 am

    for the purpose of this my crosshair is just an object that is in front of the gun and it moves with the gun

    That’s not going to work unless “eye” is located directly behind the gun barrel (gun will block the view) – if “eye” is even slightly above gun, you’ll end up looking at ground through the crosshair object, and view direction won’t match camera direction at all.

    Several ways to deal with it:

    1. Draw crosshair in the middle of screen as 2d shape, shoot bullets from the camera, and draw gun model just for show. I think that was fairly common way to do it in the “old days” (doom 1 and such)
    2. Draw crosshair in the middle of screen as 2d shape. Make a collision detection sensor (ray) that starts at the camera position, and points in same direction as camera. When user presses “fire” run a collision query using this ray sensor, and if it hits anything, fire gun at that point. That’s the only real way to deal with aiming if you’re writing 3rd person shooter.
    3. Remove cross-hair and user laser pointer/sight to aim the gun (Might look cool), shoot bullets from gun. Laser pointer ray should originate from gun, of course. This was used in zero tolerance, avp and few other games.

    Also in 3d shooters camera orientation is frequently stored as a yaw/pitch/roll combination of angles.

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

Sidebar

Related Questions

I have a VERY simple C# Winforms project that I made using Visual Studio
I have a program that loads an image from a file with DirectX using
I am making a game in C++ using DirectX. I have a basic AI
I need to make a DirectX 3D mesh at run time using Managed DirectX
ok im gonna be using directx maybe 9. I have designed two other games
I'd like to display 100 floating cubes using DirectX or OpenGL . I'm looking
I'm trying to draw a polygon using c# and directx All I get is
Hi i am developing game level editor.Currently I am using win32 with directX.But with
Using the D3DX library that is a part of directX, specifically directx9 in this
Does anyone have any direct experience (good or bad) using Jython with Google App

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.