Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Raycast and Update failure, help please.

Discussion in 'Scripting' started by Mercer88, Apr 21, 2016.

  1. Mercer88

    Mercer88

    Joined:
    Jun 11, 2014
    Posts:
    7
    // can anyone point out where my flaw is?

    Assets/Script/Player.cs(39,34): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement.

    void MakeMatch()
    {
    //Create Ray and RayCastHit variables, give the Ray an origin.
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;

    if(Physics.Raycast (ray, out hit, 20))
    {
    Debug.DrawLine(ray.origin, hit.point, Color.red);

    if(tileOne == null)
    {
    tileOne = hit.collider.gameObject;
    }
    else if(tileOne != null && hit.collider.gameObject != tileOne)
    {
    tileTwo = hit.collider.gameObject;
    }
    }
    }


    // Input trigger turn the blocks
    void Update ()
    {
    if(Input.GetMouseButtonDown(0))
    {
    //Do something.
    MakeMatch;
    }
    }
     
  2. ericbegue

    ericbegue

    Joined:
    May 31, 2013
    Posts:
    1,353
    The compiler is simply trying to tell you: "What the hell am I supposed to do here?"
     
    Mercer88 likes this.
  3. Mercer88

    Mercer88

    Joined:
    Jun 11, 2014
    Posts:
    7
    no stress got it :p