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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

CS1002 fck problem

Discussion in 'Scripting' started by unity_d33fQaVaYo1LPw, Nov 8, 2020.

  1. unity_d33fQaVaYo1LPw

    unity_d33fQaVaYo1LPw

    Joined:
    Nov 8, 2020
    Posts:
    1
    wtf i do wrong here guys????

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class PlayerController : MonoBehaviour
    {

    public float speed;
    private Rigidbody2D rb;
    private float moveInput;

    // Start is called before the first frame update
    void Start()
    {
    rb = GetComponent<Rigidbody2D>();
    }

    void FixedUpdate()
    {
    // -1 is left 0 is still 1 right
    moveInput = NewMethod()
    rb.velocity = new Vector2(moveInput*speed, rb.velocity.y);
    }

    private static float NewMethod()
    {
    return Input.GetAxis("horizontal");
    }

    // Update is called once per frame
    void Update()
    {

    }
    }
     
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,657
    CS1002 means the compiler detected a missing semicolon somewhere in your code.

    In your case, you're missing a
    ;
    after
    moveInput = NewMethod()
    .

    Please use Code tags next time and describe what error you exactly get at which line. The
    Console
    helps a lot.

    .
     
    Last edited: Nov 8, 2020
  3. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,590
    When asking for help, try to make it easy for us to help you. A good title, a problem description, using code tags, posting the error message and line the error occurs at.. all this helps. Posting unformatted code with barely any description what's wrong, and expecting people to memorize or look up error codes by their ID is not going to result in a lot of replies.
    Please have a read here: http://plbm.com/?p=220

    Additionally to what Mauri said, spelling is very important in programming. The axis label 'horizontal' does not exist, but 'Horizontal' does. That would be the next thing the compiler complains about.
     
    Last edited: Nov 9, 2020
    Antypodish and Mauri like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Bunny83 likes this.