Set LookOffSet.X value of Zoom Presets

Thiago

New member
Hi,

How can I set the value of LookOffSet.X of Preset (ZoomThirdPersonCombatPreset) at runtime.

My problem is: .When I pressed Tab, the camera changes the position relative to player..left to right, right to left.
Like this...
2021-02-09 14_48_06-Window.png

To this...
2021-02-09 14_48_21-Window.png

But, when zooming, the camera always look at to the right side of player...
2021-02-09 14_48_38-Window.png

How can I change/set the value of LookOffSet.X property of preset (ZoomThirdPersonCombatPreset)?
...or load another preset at runtime...

Sorry my spelling..
Thx a lot
Thiago
 
Last edited:
You are unable to set the preset value at runtime, but you can set the property values by getting a reference to the ViewType:

 
Hi, Justin

Thx for support!

The code below change the lookOfSet value of CameraController. Works fine. Im using playmaker to call cameraTranslate method when Tab key is pressed.

2021-02-10 09_46_58-BOE_ProjecT - Test - PC, Mac & Linux Standalone - Unity 2019.4.4f1 Persona...png

2021-02-10 09_58_27-BOE_ProjecT - Test - PC, Mac & Linux Standalone - Unity 2019.4.4f1 Persona...png

C:
public void setCameraController(CameraController cameraController) {
            this.cameraController = cameraController;
            this.viewType = this.cameraController.GetViewType<Combat>();
            //for (int i = 0; i < this.cameraController.ViewTypes.Length; i++) {
            //    Debug.Log(this.cameraController.ViewTypes[i].GetType());
            //}         
        }

        public void cameraTranslate() {
            if (this.cameraController == null) {
                return;
            }         
            Vector3 lookOfSet = this.viewType.LookOffset;
            lookOfSet.x *= -1f;
            this.viewType.LookOffset = lookOfSet;
        }

But when Aim or zoom, the camera always translate to the same X position (0.25f) loaded of preset. I just need negativate or positivate this property.

2021-02-10 09_48_07-BOE_ProjecT - Test - PC, Mac & Linux Standalone - Unity 2019.4.4f1 Persona...png

What variable or property I need set the new value (*= -1)?

Sorry if Im not seem the solution...

Thx a lot
Thiago
 
Last edited:
If there is a preset value then that preset will override the values set by your code. If you are controlling it by code then you should not use the presets for that property.
 
Top