Author Topic: How can I alter iron sight animation?  (Read 429 times)

Offline robbob42

  • Newbie
  • *
  • Posts: 30
    • View Profile
How can I alter iron sight animation?
« on: 21-07-2018, 04:07:41 »
I'm far from an experienced modder - pretty much just modifying .tweak, .inc files, etc. I've managed to import a rifle weapon from another BF2 mod for our coop play, and all is working fine but for one annoyance: when you rotate right, left, up, or down, the rifle's aim point drifts off center. When you stop rotating, it takes like 3-4 seconds for the aim point to drift back to where it should. It's particularly noticeable using iron sights where it takes 3-4 seconds for the front & rear sights to re-align themselves (once you stop moving the rifle).

This seems abnormally long - especially given that when you first bring the iron sights up it only takes a second for them to align. Why would it take 4x as long to re-align the sights when you already have them up to your eye? I'd like to drop that timespan to 1 second or less.

It seems to be something in that weapon's animation, as none of the other original weapons do this. I've looked thru various animation files, hoping to find an animationManager.length I could tweak, and even tried removing various zoom animations in the animationsystem1p.inc & animationsystem3p.inc files, but nothing seems to have any effect. What kind of animation is this (i.e. what would it be called)? There's 'turnLeft', 'turnRight', etc, but it also happens looking up or down - almost as if it's tied to the mouse look function.

I don't have access to animation software to create my own, so I'm hoping there's a setting for this somewhere that obviously eludes me. If someone could point me in the right direction that would be great!  Thanks!
« Last Edit: 21-07-2018, 19:07:29 by robbob42 »

Offline robbob42

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: How can I alter iron sight animation?
« Reply #1 on: 22-07-2018, 05:07:07 »
OK, I seemed to have figured it out. In the weapon's animationsystem1p.inc file, there is a line near the top called:
animationSystem.cameraSpring.amplitude which had values of 0.03/0.02/0.03.

It appears the 1st number controls how much the weapon swings to the side (and how far the iron sights drift out of alignment) when it's moved laterally.
The 2nd number controls how much the weapon swings up or down (and sights drift) when it's moved vertically.
Haven't figured out what the 3rd number does.

I dropped the values to:
animationSystem.cameraSpring.amplitude 0.001/0.001/0.02
and now the iron sights stay almost perfectly aligned when you swing the rifle around. If you know to look you can see them drift just a tiny fraction. I imagine even smaller values will virtually lock it in place, but this is sufficient for me.
I did drop the 3rd number a bit to see if there was any effect, but didn't see any difference. Might have been too small a change to notice anything.

Curiously, the Colt 1911's amplitude numbers are quite a bit higher at 0.1/0.035/0.2, yet its irons sights remain rock steady as you swing it around. Perhaps because it's a smaller/lighter weapon?

So, that's apparently what cameraSpring.amplitude does....