Помогите исправить ошибки в коде на C# контроллер персонажа
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[Header("Скорость перемещения")]
public float speed = 7f;
[Header("Мы на земле?")]
public bool ground;
[Header("Сила прыжка")]
public float jumpPower = 200f;
[Header("Скорость бега")]
public float runSpeed = 15f;
[Header("Скорость бега")]
public Rigibody = rb;
private void Update()
{
GetInput();
}
private void GetInput()
{
if(Input.GetKey(KeyCode.W))
{
if(Input.GetKey(KeyCode.LeftShift))
{
transform.localPosition += transform.forward * runSpeed * Time.deltaTime;
}
else
{
transform.localPosition += transform.forward * speed * Time.deltaTime;
}
}
if(Input.GetKey(KeyCode.S))
{
if(Input.GetKey(KeyCode.LeftShift))
{
transform.localPosition += -transform.forward * runSpeed * Time.deltaTime;
}
else
{
transform.localPosition += -transform.forward * speed * Time.deltaTime;
}
}
if(Input.GetKey(KeyCode.A))
{
if(Input.GetKey(KeyCode.LeftShift))
{
transform.localPosition += -transform.right * runSpeed * Time.deltaTime;
}
else
{
transform.localPosition += -transform.right * speed * Time.deltaTime;
}
}
if(Input.GetKey(KeyCode.D))
{
if(Input.GetKey(KeyCode.LeftShift))
{
transform.localPosition += transform.right * runSpeed * Time.deltaTime;
}
else
{
transform.localPosition += transform.right * speed * Time.deltaTime;
}
}
if(Input.GetKeyDown(KeyCode.Space))
{
if(ground == true)
{
rb.AddForce(transform.up * jumpPower);
}
}
}
private void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Ground")
{
ground = true;
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.tag == "Ground")
{
ground = false;
}
}
}
Помогите исправить ошибки, пишет : Invalid token ';' Invalid token '=' Скрипт должен отвечать за ходьбу прыжок и бег
Ответы (1 шт):
Автор решения: Manul74
→ Ссылка
скорее всего должно быть так.
public Rigidbody rb;
Вы не указали в какой строке ошибка. Надо привести полный текст ошибки