Search Unity

Question Assets/Scripts/ThirdPersonPlayer.cs(14,13): error CS1002: ; expected

Discussion in 'Scripting' started by Snugsockzzz, Mar 12, 2023.

  1. Snugsockzzz

    Snugsockzzz

    Joined:
    Mar 12, 2023
    Posts:
    2
    I'm New to unity and i have looked at the code multiple times and can't find the error

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ThirdPersonPlayer : MonoBehaviour
    6. {
    7. // steps1.setActive(true)
    8.         public Animator playerAnim;
    9.     public Rigidbody playerRigid;
    10.     public float w_speed, wb_speed, olw_speed, rn_speed, ro_speed;
    11.     public bool walking;
    12.     public Transform playerTrans;
    13.  
    14.     void Fixed Update(){
    15.         if(Input.GetKey(KeyCode.W)){
    16.             playerRigid.velocity = transform.forward * w_speed * Time.deltaTime;
    17.         }
    18.         if(Input.GetKey(KeyCode.S)){
    19.             playerRigid.velocity = -transform.forward * wb_speed * Time.deltaTime;
    20.         }
    21.     }
    22.     void Update(){
    23. // Walk, Backwalk, and Idle Code
    24.  
    25.         if(Input.GetKeyDown(KeyCode.W)){
    26.             playerAnim.SetTrigger("Jog");
    27.             playerAnim.ResetTrigger("Idle");
    28.             walking = true;
    29.         }
    30.         if(Input.GetKeyUp(KeyCode.W)){
    31.             playerAnim.ResetTrigger("Jog");
    32.             playerAnim.SetTrigger("Idle");
    33.             walking = false;
    34.         }
    35.         if(Input.GetKeyDown(KeyCode.S)){
    36.             playerAnim.SetTrigger("B Jog");
    37.             playerAnim.ResetTrigger("Idle");
    38.             walking = true;
    39.         }
    40.         if(Input.GetKeyUp(KeyCode.S)){
    41.             playerAnim.ResetTrigger("B Jog");
    42.             playerAnim.SetTrigger("Idle");
    43.             walking = false;
    44.         }
    45. // Rotation Code
    46.  
    47.         if(Input.GetKey(KeyCode.A)){
    48.             playerTrans.Rotate(0, -ro_speed * Time.deltaTime, 0);
    49.         }
    50.         if(Input.GetKey(KeyCode.D)){
    51.             playerTrans.Rotate(0, ro_speed * Time.deltaTime, 0);
    52.         }
    53.  
    54. // Sprint Code
    55.  
    56.         if(walking == true){
    57.             if(Input.GetKeyDown(KeyCode.LeftShift)){
    58.             w_speed = w_speed + rn_speed;
    59.             playerAnim.SetTrigger("Sprint");
    60.             playerAnim.ResetTrigger("Jog");
    61.             if(Input.GetKeyUp(KeyCode.LeftShift)){
    62.             w_speed = olw_speed;
    63.             playerAnim.ResetTrigger("Sprint");
    64.             playerAnim.SetTrigger("Jog");
    65.  
    66.         }
    67.         }  
    68.     }
    69.     }
    70. }
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,859
    This is not valid:
    Code (CSharp):
    1. void Fixed Update()
    Should be:
    Code (CSharp):
    1. void FixedUpdate()
     
    Bunny83 likes this.
  3. Snugsockzzz

    Snugsockzzz

    Joined:
    Mar 12, 2023
    Posts:
    2
    OMG Thank you!!! I have been struggling with this for the past day!