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. Dismiss Notice

Question Assets\DroneMovementScript.cs(69,84): error CS1003: Syntax error, ',' expected

Discussion in 'Editor & General Support' started by Deleted User, Apr 15, 2021.

  1. Deleted User

    Deleted User

    Guest

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

    public class DroneMovementScript : MonoBehaviour
    {

    Rigidbody ourDrone;

    void Awake(){
    ourDrone = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
    MovementUpDown();
    MovementForward();
    Rotation();

    ourDrone.AddRelativeForce(Vector3.up * upForce);
    ourDrone.rotation = Quaternion.Euler(
    new Vector3(tiltAmountForward, currentYRotation, ourDrone.rotation.z)
    );
    }

    public float upForce;
    void MovementUpDown()
    {
    if (Input.GetKey(KeyCode.I))
    {
    upForce = 450;
    }
    else if (Input.GetKey(KeyCode.K))
    {
    upForce = -200;
    }
    else if (!Input.GetKey(KeyCode.I) && !Input.GetKey(KeyCode.K))
    {
    upForce = 98.1f;
    }
    }

    private float movementForwardSpeed = 500.0f;
    private float tiltAmountForward = 0;
    private float titltVelocityForward;
    void MovementForward()
    {
    if(Input.GetAxis("Vertical") != 0) {
    ourDrone.AddRelativeForce(Vector3.forward * Input.GetAxis("Vertical") * movementForwardSpeed);
    tiltAmountForward = Mathf.SmoothDamp(tiltAmountForward, 20 * Input.GetAxis("Vertical"), ref titltVelocityForward, 0.1f);
    }
    }

    private float wantedYRotation;
    private float currentYRotation;
    private float rotateAmoutByKeys = 2.5f;
    private float rotationYVelocity;
    void Rotation()
    {
    if (Input.GetKey(KeyCode.J))
    {
    wantedYRotation -= rotationAmoutByKeys;
    }
    if (Input.GetKey(KeyCode.K))
    {
    wantedYRotation += rotationAmoutByKeys;
    }

    currentYRotation = Mathf.SmoothDamp(currentYRotation, wantedYRotation, res rotationYVelocity, 0.25f);
    }

    }



    My software is giving me this problem when I run this software above: Assets\DroneMovementScript.cs(69,84): error CS1003: Syntax error, ',' expected.
    Can you help me?
     
  2. vollukas

    vollukas

    Joined:
    Apr 6, 2019
    Posts:
    7
    On the last line instead of the reference "ref" keyword, you typed "res".

    You are welcome :p :D
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    Thank you so much. I tried very hard to find it but couldn't see that error. :)
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,533
    Also, like this thread, please use code-tags.