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

error CS1056

Discussion in 'Scripting' started by ThreeCents, Nov 18, 2018.

  1. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    I got that error : Assets/PlayerController.cs(19,34): error CS1056: Unexpected character `-' and i cant find it :(

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [RequireComponent(typeof(PlayerMotor))]
    4. public class PlayerController : MonoBehaviour {
    5.  
    6.     [SerializeField]
    7.     private float speed;
    8.  
    9.  
    10.     private PlayerMotor motor;
    11.  
    12.     private void Start()
    13.     {
    14.         motor = GetComponent<PlayerMotor>();
    15.     }
    16.  
    17.     private void Uptdate()
    18.     {
    19.         float _xMov = Input.GetAxisRaw("Horizontal");
    20.         float _zMov = Input.GetAxisRaw("Vertical");
    21.  
    22.         Vector3 _movHorizontal = transform.right * _xMov;
    23.         Vector3 _movVertical = transform.forward * _zMov;
    24.  
    25.         Vector3 _velocity = (_moveHorizontal + _movVertical).normalized * speed;
    26.  
    27.         motor.Move(_velocity);
    28.     }
    29. }
    30.  
     
    Last edited: Nov 18, 2018
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    Would you please post your code in code tags? At least this line and the nearby ones?
     
  3. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    oh my bad
    forgot about that
     
  4. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    There you go :p
     
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    Are you sure the code you have shared is the Assets/PlayerController.cs file?
    Are you sure you still have this error? What happens if you simply clear the console?
     
  6. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    Yeah im sure it's the player controller script :/ And it does nothing when I clear it
     
  7. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    _movHorizontal vs. _moveHorizontal
     
  8. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    It did nothing
     
  9. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    Can you save your files and create a screenshot about your console with the above error selected?
     
  10. kdrifter3317

    kdrifter3317

    Joined:
    May 12, 2019
    Posts:
    1
    I got the same error after downloading unity
    Please help
     
  11. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    More info? Screenshot? Code? Exact error message? Anything? No? How do you expect us to help without any info?
     
  12. LMan

    LMan

    Joined:
    Jun 1, 2013
    Posts:
    493
    Uptdate() should be Update()

    Verify you are actually running this script.

    Clean and rebuild the solution.

    If in doubt, copy the text somewhere, delete the script to trigger a rebuild, verify it's gone, make a new script, paste the code back in.
     
  13. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,004
    You're answering a post from last November. ;)
     
    LMan likes this.