因此,我有一个带有角色控制器的播放器模型,为了管理玩家的移动,我有以下文件:
using UnityEngine;
public class CharacterMovementController : MonoBehaviour {
Animator characterAnimator;
CharacterController character;
[SerializeField] Transform mainCamera;
[SerializeField] float sprintBoost = 10f;
[SerializeField] float currentSpeed = 20f;
[SerializeField] float trueSpeed;
// Start is called before the first frame update
void Start() {
characterAnimator = gameObject.GetComponent<Animator>();
character = gameObject.GetComponent<CharacterController>();
}
void Update() {
// There was a bunch of animation stuff that I figured wouldn't be important for
// you to read
Vector3 move = new Vector3(Input.GetAxis("Horizontal") * trueSpeed, 0, Input.GetAxis("Vertical") * trueSpeed);
// Movement Logic
character.Move(move * Time.deltaTime);
}
}

我已经试着把播放器的currentSpeed拖到疯狂的数字上,但仍然没有效果。我检查了字符控制器是否被正确引用,并且移动函数正在Vector3对象中传递。
发布于 2022-07-01 03:33:17
不要将输入值(Input.GetAxis("Horizontal")或Input.GetAxis("Vertical"))与move字段中的速度相乘,而是将其与整个向量相乘:
Vector3 move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
// Movement Logic
character.Move(move * Time.deltaTime * trueSpeed);有关更多信息,请参阅CharacterController.Move文档
发布于 2022-07-01 19:51:44
所以很明显,这都是关于台阶偏移,我有一个大的模型,我不得不缩小很多,这意味着偏移量必须较低,最后我使它0.01。
https://stackoverflow.com/questions/72823897
复制相似问题