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
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?
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.
Perhaps done with an animation?
Answer by OrangeLightning
Nov 22, 2011 at 08:30 PM
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.
Answer by Anxo
Nov 22, 2011 at 08:17 PM
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.
Answer by GUNcrazy115
Nov 22, 2011 at 08:29 PM
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.....
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
To help users post good questions and use the site effectively we have posted a user guide. Please check it out.
Answers and Comments
9 People are following this question.
gun sway question
Gun Rotation Sway
Child object jumps back and forth every frame
Gun object following mouse.
Gun Sway Script glitching