Creating a gun sway effect?

So as you see in most all modern FPS Games, you see sort of a Swaying effect. As in you move dramatically or just a little bit you see the gun follows the cursor/aim area but takes a little more time to get there. So I have been able find some solutions but all lead to animations, how would I go about doing this? The only solution I can find is Animations with warping.

Any suggestions? -Devon

more ▼

asked Nov 22 '11 at 05:55 AM

DevonJavaScript gravatar image

56 18 20 20

So what you mean is that you want the gun to lag behind a little bit? If you move the cursor to the right the gun will travel towards the cursor position but not instantaneously?

Nov 22 '11 at 06:10 AM Default117

Have you looked into a lerp? I am not sure if that would work, but I've used that to lag minions behind characters before.

Nov 22 '11 at 07:19 PM ChefZweegie

Perhaps done with an animation?

Nov 22 '11 at 08:19 PM Muzz5
(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

This is usually obtained by animations, however if you are like me and not having the skills or people to create such animations, this guy shows you a reasonable way of creating a decent sway effect using code only.

more ▼

answered Nov 22 '11 at 08:30 PM

OrangeLightning gravatar image

6.3k 50 61 116

(comments are locked)
10|3000 characters needed characters left

You could have the gun follow the position of the character with transform.position = character.transform.position and then "lag" the rotation by using something like RotateTowards * Time.DeltaTime so that it always takes 1 second to get to the wanted rotation.

more ▼

answered Nov 22 '11 at 08:17 PM

Anxo gravatar image

1.9k 27 31 42

(comments are locked)
10|3000 characters needed characters left

Well im not too sure, but yes the only way is animations...try making the gun a seperate peice and make a mounting spot for it. Then i think you will just have to animate the character with bobbing arms held out in position to hold the gun.

When it comes to looking around and the gun slightly tipping and following it is mostly done with movement scripts.....

more ▼

answered Nov 22 '11 at 08:29 PM

GUNcrazy115 gravatar image

1 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Nov 22 '11 at 05:55 AM

Seen: 3019 times

Last Updated: Nov 22 '11 at 08:30 PM