Have iron sights stay in center with sway?

The current sway in my game is good and all, but the sway can get in the way while aiming. I believe that simply disabling the sway while aiming isn’t a good enough solution, and I’ve seen multiple games do the same thing that I want to achieve.

Current sway:

Basically I need the sway to still be moving left and right but have the gun’s iron sight stay in the center of the screen. How can I do this?

1 Like

If you are using :PivotTo for the sway, you can try setting the pivot point of the viewmodel to the sights center.

2 Likes

Not sure what you mean by that. And I don’t think it’ll work either. But heres the code I’m using

Sway.getcf() is from an old module I scripted months ago and it’s pretty messy. I’m definitely gonna rewrite it but before I do that I need some sort of formula for keeping the sights in the center. I’m thinking CFrame.LookAt() has something to do with it.

I’ve also found a video further showing what I mean by this, just incase it was misunderstood
gif

1 Like

You can probably change the pivot point towards the barrel of the gun.

This should change the center of rotation.

BasePart.PivotOffset
2 Likes

I might be far too late to the discussion, but I wanna add to what @dthecoolest was saying.

You can use the pivot point of the PrimaryPart.
What I did was, first I made the PrimaryPart’s CFrame match the camera’s with an offset. Then, I used the PivotTo and did PrimaryPart:GetPivot() * SwayOffset . It worked out pretty well, just look at this:

de028b4bb20beac102ef5eda6ba48168

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.