我想在斜坡上移动球,就像在平地上移动一样。目前当斜坡开始时,球的速度会降低,所以根据玩家的经验,球的整体运动会降低。
我想保持同样的速度,当它在地面上移动或马虎的地区。
尽管下面这张图我试图解释我的问题:
void FixedUpdate ()
{
if (!GameManager.Instance.IsGameRunninng) {
myRigidBody.velocity = Vector3.zero;
return;
}
if (isJumper) {
isJumper = false;
myRigidBody.AddForce (Vector3.up * 35f, ForceMode.Impulse);
}
isGrounded = Physics.Raycast (rayTransform.position, Vector3.down, 0.5f, groundMask);
Vector3 nextVelocity = myRigidBody.velocity;
nextVelocity.x = ballInputHandler.horizontalInput * smoothnessX;
if (!isGrounded) {
nextVelocity.y -= speed * 0.3f;
} else {
nextVelocity.y = 0;
nextVelocity.z = speed;
}
myRigidBody.velocity = Vector3.Lerp (myRigidBody.velocity, nextVelocity, smoothnessValue * Time.fixedDeltaTime);
ClampingBallMovement ();
}
我希望你正确地理解了我的问题,给我一些建议,这样我就可以从这个问题中走出来。