今月のコード
Unity/C#研究中です。
private Rigidbody rb;
private float speed = 30f;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
if (rb.velocity.magnitude < 10)
{
float currentSpeed = speed – rb.velocity.magnitude;
rb.AddForce(new Vector3(0, 0, currentSpeed));
}
}