[英]Why isn't the Move function in Character Controller not moving my player?
所以我有一個帶有角色控制器的玩家模型,為了管理玩家的移動,我在下面有這個文件:
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 拖到瘋狂的數字上,但仍然沒有任何效果。 我檢查了字符控制器是否被正確引用,並且 Move 函數正在 Vector3 對象中傳遞
不要將輸入值( 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
文檔
所以顯然這都是關於步距偏移的,我有一個大模型,我必須縮小很多,這意味着偏移必須非常低,最后我把它設為 0.01
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.