Вот скрипты:
Скрипт Player Motor:< /p>
Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 playerVelocity;
private PlayerLook look;
private float speed = 5f;
public float crouchSpeed = 2.5f;
public float walkSpeed = 5f;
public float sprintSpeed = 8f;
public float jumpHeight = 0.6f;
private float crouchTimer = 1f;
public float gravity = -9.8f;
private float standingHeight = 2;
private float crouchingHeight = 1;
private float targetHeight = 2;
private bool isGrounded;
private bool crouching= false;
private bool sprinting = false;
private bool lerpCrouch=false;
Vector3 initialCameraPosition;
void Start()
{
controller = GetComponent();
look = GetComponent
();
initialCameraPosition = look.cam.transform.localPosition;
}
// Update is called once per frame
void Update()
{
isGrounded = controller.isGrounded;
if(lerpCrouch)
{
crouchTimer += Time.deltaTime;
float p = crouchTimer / 1;
p *= p;
if(controller.height1)
{
lerpCrouch = false;
crouchTimer = 0f;
}
}
}
public void ProcessMove(Vector2 input)
{
Vector3 moveDirection = Vector3.zero;
moveDirection.x = input.x;
moveDirection.z = input.y;
controller.Move(transform.TransformDirection(moveDirection)*speed*Time.deltaTime);
playerVelocity.y += gravity * Time.deltaTime;
if(isGrounded &&playerVelocity.y
Подробнее здесь: [url]https://stackoverflow.com/questions/78801407/cant-get-the-controller-velocity-it-is-always-0-0-0[/url]