Change FOV Runtime

MarkusKer

Member
Hello,

after checking the documentation and trying to change the FOV from a script with presets i kind of got stuck.
As i am understood teh correct way to change the FOV Amount with Presets. I created a ned "Standard Preset"to override the default Preset. This was working great but i have to change the value of this preset somehow during runtime.

Or is there an better solution to changing the FOV?

Thanks,
Markus
 

MarkusKer

Member
thank you it was very easy to access the value via:
CameraMain.GetComponent<CameraController>().GetViewType<Opsive.UltimateCharacterController.ThirdPersonController.Camera.ViewTypes.Adventure>().FieldOfView = 110;

I am just having two problems left. I need to change the FOV of a preset as well, in this case the ZoomThirdPersonAdventurePreset. Otherwise the standard FOV is way to high in relation to the zoomed state.

Also i noticed that i can subscribe to the OnZoom event as documented but ran into a little problem. I am not sure if it is intendet or not but if i start the zoom state with "Button Down"and stop it with "Button Down Continuous" the camera beheaves perfectly but the Zoom event bool turns false as soon as i lift the button up and not at the toggle. I think it should be disabled as soon as the item ability stops or am i wrong?

Regards,
Markus
 

Andrew

Moderator
Staff member
You can't directly edit the values of a preset during runtime - instead, you should use another preset that overrides/blocks that preset when a particular state is active.

You probably shouldn't be using Button Down for start and Button Down Continuous for stop for an ability - what's the exact behaviour you're trying to create here?
 

MarkusKer

Member
Is there any better way to change the FOV of the aim State. If i have to create a preset for every possible fov (for example 40-110) it would take a long time.
 

Andrew

Moderator
Staff member
I assume this is for an FOV slider option? The easiest way might be to remove the FOV value from the Zoom preset, and if you still need to adjust the FOV upon zooming then you could do that through code. (e.g. a sub-class of the Zoom ability that adjusts the camera's FOV value when the ability starts or stops).
 

MarkusKer

Member
Thank you i implemented a script i wrote on my own like you suggested. It is working but i still need the ability to stop just when i toggle the button and not if i lift it up immediately.

Regards,
Markus
 

Andrew

Moderator
Staff member
Is this a "Generic" ability? Is there any animation tied to it / what are the "Stop event" settings for the ability?
 

MarkusKer

Member
I am talking about the default item aim ability every character controller gets after creation. Under the aim ability on the camera there is an option for (Onstate change). In fact this state changes not if the ability stops but when i lift the corresponding mouse button. I am using button down to start the aim ability and the ability is active until i toggle the button(for ending the ability) .The bool (onZoom) changes to false right after i lift the mouse button even if the ability is still active. In my opinion the bool should change to false if i toggle the button and the state is inactive again. Otherwise the only way to use the "Onstate change" trigger is when the aim ability uses "button down continuous".
 

Andrew

Moderator
Staff member
Ah, I see. The problem here is that the OnZoom event is called by the CameraController, which simply detects if the zoom input is currently held or not, and is actually not related to the Aim ItemAbility (e.g. if you disable "Can Zoom" in the CameraController, the OnZoom event won't get called at all). An easier way to do it would be to simply check if the "Aim" state is active instead.
 

MarkusKer

Member
Alright thanks.

I am accessing the aim ability now directly. I set up the state system to stop aiming if i use the grenade or reload for example. This is now obviously now working either, I wanted to stop the aim Ability via code and it worked great for the reloading:

if ((characterLocomotion.GetAbility<Reload>().IsActive == true) || (characterLocomotion.GetAbility<EquipUnequip>().IsActive == true))
{
zoom = false;
}

But how do i access an specific use ability and check if it is active. For example the grenade whichis slot one.

if (characterLocomotion.GetAbility<Use>().IsActive == true) Slot1???
{
zoom = false;
}

Regards,
Markus
 

Andrew

Moderator
Staff member
You can specify the ability index as a parameter of GetAbility, i.e.: GetAbility<Use>(index).
 
Top