Hello, I have error:
Assets\CharacterController.cs(57,5): error CS1022: Type or namespace definition, or end-of-file expected
there is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
{
public CharacterController controller;
public Transform playerCamera;
public float speed = 6f;
public float sprintSpeed = 10f;
public float sensitivity = 2f;
public float jumpHeight = 3f;
private float rotationX = 0f;
void Update()
{
// Player movement
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
Vector3 velocity = direction * speed;
}
// Sprinting
if (Input.GetKey(KeyCode.LeftShift))
{
velocity = direction * sprintSpeed;
}
// Applying gravity
if (!playerController.isGrounded)
{
velocity.y += Physics.gravity.y * Time.deltaTime;
}
playerController.Move(velocity * Time.deltaTime);
// Player jumping
if (Input.GetButtonDown("Jump") && playerController.isGrounded)
{
velocity.y = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y);
}
// Player looking around
float mouseX = Input.GetAxis("Mouse X") * sensitivity;
float mouseY = Input.GetAxis("Mouse Y") * sensitivity;
rotationX -= mouseY;
rotationX = Mathf.Clamp(rotationX, -90f, 90f);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}
}