Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

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,649
    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,649
    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.