Ошибка CS1002: ; expected указывает на недостающую точку с запятой в коде. Судя по вашему коду, ошибка находится в этом фрагменте:
else if (Input.GetKey.LeftControl))
Здесь некорректно использован метод Input.GetKey. Должно быть Input.GetKey(KeyCode.LeftControl). Поправим этот участок кода и проверим весь код на наличие ошибок.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerControll : MonoBehaviour
{
public GameObject cam;
Quaternion StartRotation;
float ver, hor, Jump, RotHor, RotVer, Speed;
public float RunSpeed = 15f, StepSpeed = 5f, NormSpeed = 10f, JumpSpeed = 100f, sens = 5f;
bool isGround;
void Start()
{
StartRotation = transform.rotation;
}
void OnCollisionStay(Collision other)
{
if (other.gameObject.tag == "ground")
{
isGround = true;
}
}
void OnCollisionExit(Collision other)
{
if (other.gameObject.tag == "ground")
{
isGround = false;
}
}
void Update()
{
if (Input.GetKey(KeyCode.LeftShift))
{
Speed = RunSpeed;
}
else if (Input.GetKey(KeyCode.LeftControl)) // Исправлено здесь
{
Speed = StepSpeed;
}
else
{
Speed = NormSpeed;
}
RotHor += Input.GetAxis("Mouse X") * sens;
RotVer += Input.GetAxis("Mouse Y") * sens;
RotVer = Mathf.Clamp(RotVer, -60, 60);
Quaternion RotY = Quaternion.AngleAxis(RotHor, Vector3.up);
Quaternion RotX = Quaternion.AngleAxis(-RotVer, Vector3.right);
cam.transform.rotation = StartRotation * transform.rotation * RotX;
transform.rotation = StartRotation * RotY;
if (isGround)
{
ver = Input.GetAxis("Vertical") * Time.deltaTime * Speed;
hor = Input.GetAxis("Horizontal") * Time.deltaTime * Speed;
Jump = Input.GetAxis("Jump") * Time.deltaTime * JumpSpeed;
GetComponent().AddForce(transform.up * Jump, ForceMode.Impulse);
}
transform.Translate(new Vector3(hor, 0, ver));
}
}
### Объяснение изменений:
- В строке else if (Input.GetKey.LeftControl)) было Input.GetKey.LeftControl), что является неправильным синтаксисом.
- Исправлено на else if (Input.GetKey(KeyCode.LeftControl)).
вот код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerControll : MonoBehaviour
{
public GameObject cam;
Quaternion StartRotation;
float ver, hor, Jump, RotHor, RotVer, Speed;
public float RunSpeed = 15f, StepSpeed = 5f, NormSpeed = 10f, JumpSpeed = 100f, sens = 5f;
bool isGround;
void Start()
{
StartRotation = transform.rotation;
}
void OnCollisionStay(Collision other)
{
if (other.gameObject.tag == "ground")
{
isGround = true;
}
}
void OnCollisionExit(Collision other)
{
if (other.gameObject.tag == "ground")
{
isGround = false;
}
}
void Update()
{
if(Input.GetKey(KeyCode.LeftShift))
{
Speed = RunSpeed;
}
else if (Input.GetKey.LeftControl))
{
Speed = StepSpeed;
}
else
{
Speed = NormSpeed;
}
RotHor += Input.GetAxis("Mouse X") * sens;
RotVer += Input.GetAxis("Mouse Y") * sens;
RotVer = Mathf.Clamp(RotVer, -60, 60);
Quaternion RotY = Quaternion.AngleAxis(RotHor, Vector3.up);
Quaternion RotX = Quaternion.AngleAxis(-RotVer, Vector3.right);
cam.transform.rotation = StartRotation * transform.rotation * RotX;
transform.rotation = StartRotation * RotY;
if (isGround)
{
ver = Input.GetAxis("Vertical") * Time.deltaTime * Speed;
hor = Input.GetAxis("Horizontal") * Time.deltaTime * Speed;
Jump = Input.GetAxis("Jump") * Time.deltaTime * JumpSpeed;
GetComponent<Rigidbody>().AddForce(transform.up * Jump, ForceMode.Impulse);
}
transform.Translate(new Vector3(hor, 0, ver));
}
}