Creating a Smooth Zoom

Post » Sun Aug 24, 2014 10:07 pm

A while back I tried to add a zoom feature for my mod http://www.nexusmods.com/skyrim/mods/55475/?. This was basically the code:

;Zoom Vars;------------Float ZoomAmountBool PressedOnceZoom = False Int ZoomHotkey = 24; Initial value O "Out"Bool ZoomHotkeyEnable = False; zoom hotkey initially disabled;this was the actual function for zoomFunction ZoomIn()	ZoomAmount = Utility.GetINIFloat("fDefaultWorldFOV:Display") as Float	Debug.ToggleMenus()	;Utility.Wait(0.5)	Game.ShowFirstPersonGeometry(false)	Utility.SetINIFloat("fDefaultWorldFOV:Display", 12)	;Utility.Wait(0.05)		Input.TapKey(Input.GetMappedKey("Tween Menu"))	;Utility.WaitMenuMode(0.3)	Input.TapKey(Input.GetMappedKey("Tween Menu"))	;Utility.Wait(0.05)		PressedOnceZoom = true	;Utility.Wait(0.05)		Debug.ToggleMenus()	EndFunctionFunction ZoomBackOut()	Debug.ToggleMenus()	;Utility.Wait(0.05)	Game.ShowFirstPersonGeometry()	Utility.SetINIFloat("fDefaultWorldFOV:Display", ZoomAmount)	;Utility.Wait(0.05)		Input.TapKey(Input.GetMappedKey("Tween Menu"))	;Utility.WaitMenuMode(0.3)	Input.TapKey(Input.GetMappedKey("Tween Menu"))	;Utility.Wait(0.05)		PressedOnceZoom = False	;Utility.Wait(0.05)		Debug.ToggleMenus()			EndFunction

I commented those lines out after some testing. But it essentially worked like so:

Pause, zoom. - zooming in

Pause, open inventory menu, zoom out - zooming out

I actually originally looked at the code in Mofakin's mod Hotkey Mod for this. But I got rid of the feature because it was pretty jerky and not a smooth zoom at all.

Does anyone know what a smoother zoom function might require, or why the other one as so jerky (and I did try commenting out the Input.TapKey sections and it remained as jerky):

User avatar
Rhi Edwards
 
Posts: 3453
Joined: Fri Jul 28, 2006 1:42 am

Post » Sun Aug 24, 2014 10:37 pm

The jerkyness is dependend on your machine and the correct usage of the Utility.Wait() code. If your machine isn't as efficient as mine, you will jerk. If it's more, and I mean much more, effecive, then it can also get jerki. The problem is, FOV changes via script will only be accepted once you've entered a menu, go into sneak stance or do similar stuff. You could use Game.DisablePlayerControls() for the moment, because part of the jerkiness results of pressing the key to long, but as far as I remember this wouldn't work on said function, that'S the reason why I took it out.

User avatar
Jade Payton
 
Posts: 3417
Joined: Mon Sep 11, 2006 1:01 pm

Post » Sun Aug 24, 2014 7:22 pm

Ah. Oh well. Good to know. Thanks :smile:.

User avatar
Juanita Hernandez
 
Posts: 3269
Joined: Sat Jan 06, 2007 10:36 am


Return to V - Skyrim