Forum rules - please read before posting.

Calling pitchLock / spinLock

edited August 25 in Technical Q&A

Hi,

I used to use this script, attached to MainCamera, to trigger pitchLock / spinLock ... but at somepoint after upgrading its stopped working, I just dont know enough code to see what to fix.

Can anyone tell me what to change?

using System.Collections;
using UnityEngine;
using AC;

namespace AC
{
    public class WarpCamRotateLock : MonoBehaviour
    {
        public void LockCam()
        {
        this.GetComponent <GameCameraThirdPerson>().pitchLock = RotationLock.Locked;
        this.GetComponent <GameCameraThirdPerson>().spinLock = RotationLock.Locked;
        }

        public void UnlockCam()
        {  
        this.GetComponent <GameCameraThirdPerson>().pitchLock = RotationLock.Limited;
        this.GetComponent <GameCameraThirdPerson>().spinLock = RotationLock.Free;
        }
    }
}

Comments

  • edited August 25

    I can't spot pitchLock or RotationLock in the scripting guide, I must be looking in the wrong place - or has GameCameraThirdPerson no longer got pitchLock and spinLock ?

  • It doesn't have those variables, no. Your script may be referencing an older version that used to be on the Downloads page, rather than the integrated one.

    The one included with AC has an inputInfluence Vector2 variable that controls how much input affects rotation. You could zero this to prevent the user from moving the camera i.e.:

    GetComponent<GameCameraThirdPerson>().inputInfluence = Vector2.zero;
    
  • Ok, yes quite possible, os that will produce the same result as lock then, I can just switch the content of that function and all exising calls will work.

    How would I then reproduce the now gone 'unlock', so as to return to the existing input? As different Scene cameras already have different settings, i'd want to go 'back' to however the were pre locked/zero'd - it want to return Pitch to its previous limted setting and spin to previous free.

  • You can either set inputInfluence to values that you manually keep track of, i.e.:

    GetComponent<GameCameraThirdPerson>().inputInfluence = new Vector2(3f, 3f);
    

    Or record the original values before affecting them:

    Vector2 originalInputInfluence;
    
    void Start() => originalInputInfluence = GetComponent<ThirdPersonCamera>().inputInfluence;
    
    GetComponent<ThirdPersonCamera> ().inputInfluence = originalInputInfluence;
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.