Search Unity

Cannot be used in this context because it lacks the `get' accessor

Discussion in 'Getting Started' started by Shadowing, Mar 5, 2015.

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Error: Opsive.ThirdPersonController.RigidbodyCharacterController.AlwaysAim' cannot be used in this context because it lacks the `get' accessor

    Not sure how to use the get accessor. weirdly enough can't seem to google this question.

    Code (csharp):
    1. AlwaysAimSetting = GetComponent<RigidbodyCharacterController>().AlwaysAim;
    Trying to do that so I can set it true or false later in the script with
    Code (csharp):
    1. AlwaysAimSetting = true;
    Anyone know what I'm needing here thanks.
    Cheers!
     
    Last edited: Mar 5, 2015
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Bools are a value type. So this wouldn't work anyway. Try this.

    Code (csharp):
    1. characterController = GetComponent<RigidbodyCharacterController>();
    Code (csharp):
    1. characterController.AlwaysAim = true;
    Note I haven't checked the docs on this.
     
  3. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    oh ya that's a good idea lol. Idk why I didn't think about saving that component instead.

    so can components only be saved to variables or what.