Why does my code have a syntax error?

I get this Assets\ThirdPersonMovement.cs(9,33): error CS1003: Syntax error, ‘,’ expected and I’m not sure why. Can anyone please help. :slight_smile:

using UnityEngine;

public class ThirdPersonMovement : MonoBehaviour
{
    public CharacterController controller;

    public float speed = 6f;

    public float turnSmoothTime - 0.1f;

    float turnSmoothVelocity;

    // Update is called once per frame
    void Update()
    {
        float horizontal = Input.GetAxisRaw("Horizontal");
        float vertical = Input.GetAxisRaw("Vertical");
        Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;

        if (direction.magnitude >= 0.1f)
        {
            float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
            float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
            transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);
            controller.Move(direction * speed * Time.deltaTime);
        }
    }
}

You need to change the minus sign to equals sign in line 9: public float turnSmoothTime = 0.1f;

When you copy code, be sure to double-check everything. Any errors will indicate the line you should focus on.

i love you homie

1 Like