• Advertisement
Sign in to follow this  

Make Gun always visible

This topic is 3828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I am making a FirstPersonShooter and i have a problem with the players gun. When hitting a wall and sliding my gun is hidden by the wall. ive tried to set my sphere-radie longer so it wont be hidden, but this distance is too much. i still want be able to slide close to any wall and still see the gun. how do i do this?

Share this post


Link to post
Share on other sites
Advertisement
Not that I'm a real FPS expert, but I think you need to render the scene and your gun on different Z levels.

You should render your scene in one pass, and your gun in the second. To seperate them, use Begin and End Scene.

EDIT: I'm not sure I did a real great job of explaining :D . Let me type in the language I know best.

Begin Scene;
render world;
End scene;

Begin scene;
render gun;
end scene;

Share this post


Link to post
Share on other sites
hi, ive tried that, did not work, might be easier with some code...

device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
device.BeginScene();
UpdateInputState();

SetupCamera();
RenderLights();

level1.DrawMesh(ref device);

device.EndScene();

device.BeginScene();

gun.DrawMesh(ref device);
gun.meshPos.z = -3;
gun.meshPos.x = -2;
gun.meshPos.y = -2;

gun.yaw = -0.1f;
gun.pitch = 0.05f;

device.EndScene();
device.Present();
this.Invalidate();

Share this post


Link to post
Share on other sites
tnx mate, you were right =)

I only turned off the Z-buffer flag and it worked!

device.Clear(ClearFlags.ZBuffer, Color.Black, 1.0f, 0);

tnx!

Share this post


Link to post
Share on other sites
thought it was somethin like that.

Although, if you turned off the Z-buffer flag, you might want to make your gun move around a little bit and make sure it's not drawing itself without erasing. I one tripped over the horror of doing this. My gun was drawing on the screen like a crayola.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement