Search Unity

error CSO119

Discussion in 'Scripting' started by AlbertoT, Mar 28, 2010.

  1. AlbertoT

    AlbertoT

    Joined:
    Mar 27, 2009
    Posts:
    159
    Hello

    I have been testing Unity3d with JavaScript for a couple of months,no problem
    Now I am tring C#

    I have a robot with a CharacterController attached

    I declare

    static CharacterController controller;

    void Start () {
    controller = (CharacterController)GetComponent(typeof(CharacterController)); }

    CollisionFlags flags = controller.Move(....);

    but I get the error message

    Expression denotes a "Type" where a "variable" "value" or "Method group" was expected

    What shall I do ?

    Thanks in advance for support
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    There doesn't seem to be anything wrong with the code you've posted. Can you post the whole script and mention which line is causing the error?
     
  3. AlbertoT

    AlbertoT

    Joined:
    Mar 27, 2009
    Posts:
    159
    Thanks

    I quoted the whole script
    I have created a C sharp script and I wrote just these few lines of code

    The line causing the error is

    CollisionFlags flags = controller.Move(....);

    If I switch to a JavaScript with

    var controller : CharacterController = GetComponent(CharacterController);

    it works well
     
  4. Tempest

    Tempest

    Joined:
    Dec 10, 2008
    Posts:
    1,286
    You're getting an error because your controller is static. Make it public, or private instead.