나는 이상한 결함이 있습니다. 구석에서 내려올 때 (나는 누르지 않습니다.) 플레이어는 매우 빠른 속도로 떨어질 것입니다. 내가 점프하면 모든 것이 정상적으로 진행됩니다. (내가 대신 컨트롤러에 내장 된 사용 해달라고 왜 그게 전부 그래서 그 Quill18 FPS 컨트롤러, 내가 거기에서 알아보기)Unity/C# FPS 컨트롤러의 이상한 결함
using UnityEngine;
using System.Collections;
[RequireComponent (typeof(CharacterController))]
public class FirstPersonController : MonoBehaviour
{
public float movementSpeed = 5.0f;
public float mouseSensitivity = 5.0f;
public float jumpSpeed = 20.0f;
float verticalRotation = 0;
public float upDownRange = 60.0f;
float verticalVelocity = 0;
CharacterController characterController;
// Use this for initialization
void Start()
{
// Screen.lockCursor = true;
characterController = GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
// Rotation
float rotLeftRight = Input.GetAxis("Mouse X") * mouseSensitivity;
transform.Rotate(0, rotLeftRight, 0);
verticalRotation -= Input.GetAxis("Mouse Y") * mouseSensitivity;
verticalRotation = Mathf.Clamp(verticalRotation, -upDownRange, upDownRange);
Camera.main.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
// Movement
float forwardSpeed = Input.GetAxis("Vertical") * movementSpeed;
float sideSpeed = Input.GetAxis("Horizontal") * movementSpeed;
verticalVelocity += Physics.gravity.y * Time.deltaTime;
if (characterController.isGrounded && Input.GetButton("Jump"))
{
verticalVelocity = jumpSpeed;
}
Vector3 speed = new Vector3(sideSpeed, verticalVelocity, forwardSpeed ;
speed = transform.rotation * speed;
characterController.Move(speed * Time.deltaTime);
}
}
이것이 이상한 현상입니까? 즉, 점프보다 서있는 가을부터 더 빨리 주어진 아래쪽 속도에 도달하게됩니다. 즉 운동학이 작동하는 방식입니다. –
예, 제가 뛰어 내리지 않으면 위층에서 내려주세요. 거의 텔레포트처럼 바닥에 있습니다. –
좋아요. 유니티 개발자가 아니에요. 확실히 모르겠지만 어쩌면 문제는 y 위치가 현재 캐릭터 밑에있는 땅의 높이에 비례해서 측정된다는 것입니까? 따라서 캐릭터가 실제로 일정한 y 위치를 유지하며 선회를하지 않고 가속이 일어나지 않고 단지 y = 0의 위치가 더 낮게 이동했습니다. –