【发布时间】:2020-04-16 21:27:59
【问题描述】:
这个脚本附加到我的具有刚体组件的播放器上。 刚体使用重力和运动学设置为ture。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RigidbodyPlayercontroller : MonoBehaviour
{
Rigidbody rb;
public float speed;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
float mH = Input.GetAxis("Horizontal");
float mV = Input.GetAxis("Vertical");
rb.velocity = new Vector3(mH * speed, rb.velocity.y, mV * speed);
}
}
但是玩家没有移动它什么都不做。我尝试了速度值 1 和 100。
【问题讨论】: