为什么在字符控制器中不移动我的播放器中的移动功能?
因此,我有一个带有字符控制器的播放器模型,并且要管理播放器移动,我以下文件:
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);
}
}
< img src =“ https://i.sstatic.net/pogqq.png” alt =“组件“>
我已经试图将玩家的Currentspeed拖到疯狂的数字上,但仍然没有任何作用。我检查了字符控制器正在正确引用,并且移动函数正在vector3对象中传递
So I have a player model with a character controller attached and to manage the player movement I have this file below:
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);
}
}
I already tried to drag the currentSpeed of the player to insane numbers and still nothing works. I checked that the character controller is properly being referenced and the Move function is being passed in a Vector3 object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,显然这一切都是关于阶跃偏移的,我有一个大型型号,我必须缩小很多尺寸
So apparently it was all about the Step offset, I had a large model which I had to scale down a lot meaning the offset had to be suer low, in the end I made it 0.01
请勿将输入值(
input.getAxis(“ Horizontal”)
或input.getAxis(“ vertical”)
)与移动字段,将其与总体向量相乘:
请参阅
pronage> prinatecontroller.move
Do not multiply the input value (
Input.GetAxis("Horizontal")
orInput.GetAxis("Vertical")
) with the speed in themove
field, multiply it with the overall vector instead:Refer to the
CharacterController.Move
documentation for more info