Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Proper FPS Recoil

Author
Message
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 24th Sep 2009 23:40
Hi! I've been trying to get proper recoil in my FPS game for a few days now but I'm having trouble. What I mean by proper is the closer you get to a wall the more accurate it is and the farther away you get the more inaccurate it gets. Shooting in general also decreases your accuracy. I'm trying to make the recoil by rotating the camera in a random direction on the X and Y axis so it's pointing the direction the bullet will go then I move the camera forward far then reset it's position/rotation and ray cast for collisions. Where I'm having troubles is rotating it along the X and Y axis so it properly resembles realistic gun accuracy. I had it working but the problem was, was that after shooting in a single area it made a checker board pattern so it wasn't circular and it had perfect distance between each shot. So what is a formula I could use to get the value to rotate the camera along the X and Y axis so that when I shoot it would eventually form a circle?

P.S. I know I made a thread a bit back regarding this issue but that was revolving around a game that uses different values then my current one does and I lost it in a hard drive crash.

Games are like life, they should never stand still.
Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 25th Sep 2009 15:59
Well, The most simple thing that I can think of right now is something like: acc=waepacc/(distance+weaponrec)/x

waepacc= base weapon accuracy
weaprec= Weapons base recoil
x is a number to fill in just to make it more precice, so it would sorta be: acc=20/(40+5)/3

then you need a random number between 0 and hunderd, and then:
if ( randnum < acc ) then hit else miss.

It seems sorta basic, and if you want the cross to move like upwards or downwards, you just need to add acc/x to the position of your weapon and then it will move a bit.

Hope I made myself clear enough.

Isocadia
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 25th Sep 2009 21:52
Ok well I think I understand what you are saying but, I'm trying to determine the accuracy before I hit anything so there is no way for me to know the distance that is required in that formula. Also I don't want the collision itself to be random but I want the direction that the bullets travel to be random. So this code:

Would be pointless for what I'm trying to accomplish. Thanks for your idea though!

Games are like life, they should never stand still.

Login to post a reply

Server time is: 2024-11-19 05:58:42
Your offset time is: 2024-11-19 05:58:42