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

help with c# pls

Discussion in 'Scripting' started by The55Boom, Jun 18, 2020.

  1. The55Boom

    The55Boom

    Joined:
    Jun 18, 2020
    Posts:
    2
    i keep geting
    Assets\PlayerMovement.cs(25,18): error CS1002: ; expected

    so heres my script pls help

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PlayerMovement : MonoBehaviour
    {
    public CharacterController controller;
    public float speed = 12f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;
    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;
    Vector3 velocity;
    bool isGrounded;
    // Update is called once per frame
    void Update()
    {
    isGrounded = Physics.CheckCapsule(groundCheck.position, groundDistance, groundMask);
    if(isGrounded && velocity.y < 0);
    {
    velocity.y = -2f;
    }
    float x = Input.GetAxis("Horizontal");
    float z = Input.GetAxis("Vertical");
    Vector;3 move = transform.right * x + transform.forward * z;
    controller.Move(move * speed * Time.deltaTime);
    if(Input.GetButtonDown("Jump") && isGrounded);

    {
    velocity.y = Mathf.Sqrt(jumpHeight * -2 * gravity);
    }
    velocity.y += gravity * Time.deltaTime;
    controller.Move(velocity * Time.deltaTime);
    }
    }
     
  2. dahiyabunty1

    dahiyabunty1

    Joined:
    Jan 22, 2020
    Posts:
    68
    if(isGrounded && velocity.y < 0);

    remove this semicolon
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,970
  4. The55Boom

    The55Boom

    Joined:
    Jun 18, 2020
    Posts:
    2
    so i did but it still says i need a semicolin some where if u know pls help
     
  5. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    The numbers next to the error message tell you where.
    IE: (25,18) = line 25, character 18.
     
    PraetorBlue likes this.
  6. frasderp

    frasderp

    Joined:
    Oct 6, 2016
    Posts:
    19
    Remove the semicolon at the end of this also

    if(Input.GetButtonDown("Jump") && isGrounded);

    if statements should look like this:

    Code (CSharp):
    1. if(check = 1)
    2. {
    3.  
    4. your code here;
    5.  
    6. }
    7.