Search Unity

Noob problem

Discussion in 'Getting Started' started by Zecrit, Feb 3, 2016.

  1. Zecrit

    Zecrit

    Joined:
    Jan 28, 2016
    Posts:
    2
    I'm starting with a basic 2D platformer and using the provided tutorial on this website.
    I found this error, in the error list it says exactly this:

    CS1031 - Type expected - New unity project 2.CSharp - [scriptname] - [line] - active

    Area:
    void FixedUpdate()
    {
    float h = Input.GetAxis("Horizontal");
    anim.SetFloat("Speed", Mathf.Abs(h));

    if (h * rb2D.velocity.x is < maxSpeed) -----< the "<" is underlined red.
    rb2D.AddForce(Vector2.right * h * moveForce);
    if (Mathf.Abs(rb2D.velocity.x) > maxSpeed)
    -etc

    I'm sure it's exactly as written in the tutorial, I'm writing in visual studio, I have no idea what is wrong.
     
  2. Farelle

    Farelle

    Joined:
    Feb 20, 2015
    Posts:
    504
    why do you have "is" inside the code infront of the < ? it's certainly not belonging there
     
    jhocking and JoeStrout like this.
  3. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    @Zecrit you should use code tags to format the code to be easier to read on the forums:

    http://forum.unity3d.com/threads/using-code-tags-properly.143875/

    Also, anything your pointing out in the code should have comment as if it were written in the code itself ( ya'know like "// this line does x thing" )

    I think you should copy paste the entire script so we can see that everything looks right, and please use the formatting from that link above.