Search Unity

Error CS1002 expected

Discussion in 'Scripting' started by danielhglz10, Jul 7, 2020.

  1. danielhglz10

    danielhglz10

    Joined:
    Jul 7, 2020
    Posts:
    2
    Im new in Unity and scripting, I made this script but in appears the error CS1002 expected
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [RequireComponent(typeof(CharacterController))]
    6. public class Playercontroller : MonoBehaviour
    7. {
    8.     public float walkSpeed = 5f;
    9.  
    10.     Vector3 moveinput = Vector3.zero;
    11.     CharacterController characterController;
    12.  
    13.     private void Awake()
    14.     {
    15.         characterController = GetComponent<CharacterController>();
    16.     }
    17.  
    18.     private void Update()
    19.     {
    20.         Move();
    21.     }
    22.  
    23.     private void Move()
    24.     {
    25.         moveinput = new Vector3(Input.GetAxisGetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
    26.         moveinput = transform.TransformDirection(moveinput) = walkSpeed;
    27.  
    28.         characterController.Move(moveinput = Time.deltaTime);
    29.     }
    30. }
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    When posting for help, please provide as much detail as possible, such as the actual error, and highlight the lines the error occurs.

    In your case though, there is no method named GetAxisGetAxis. I am sure you meant to just use GetAxis there.

    Also, the TransformDirection method returns a Vector, you cannot assign the walkSpeed float to it. I suspect you meant to multiple it by that there, the same goes for the code in the Move method call for the character controller.

    If you use an ide such as Visual Studio, it should highlight those errors when you look at the code with a nice prominent squiggly line under the parts of the code causing the errors.
     
  3. danielhglz10

    danielhglz10

    Joined:
    Jul 7, 2020
    Posts:
    2
    Thank you, I found the problem and changed the code