Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.67k stars 326 forks source link

FPS Weapon Movement variable #2654

Open RedRoryOTheGlen opened 2 months ago

RedRoryOTheGlen commented 2 months ago

Adds an Offset variable that lets other scripts move the FPS Weapon sprite while preserving the original weaponPosition variable, mostly made to support mods that add weapon sway/bob.

SAMPLE of Offset working with mod (not included)

If nothing tries to change the FPSWeapon Offset, it should behave entirely like usual. I hope. Suggestions for better implementation are always welcome.

RedRoryOTheGlen commented 1 month ago

Old Offset variable was renamed to Position. Added two new variables: Scale and Offset (new).

  1. Scale allows a mod to change the size of the sprite.
  2. The new Offset variable allows a mod to change the position of the sprite relative to its width/height without having access to the original weaponPosition rect. For example, adding a value of 0.5 to Offset.x will move the sprite horizontally by sprite.width/2 pixels.

Added a reset to the variables in LateUpdate. This lets multiple mods simultaneously affect the Position, Scale and Offset of FPSWeapon.

It should behave entirely like usual as before. I think only the LateUpdate check would run as long as the variables are all zero'd.