Explorar o código

修改移动参数

zhengchen hai 1 ano
pai
achega
db3db05232
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      Assets/Scripts/Comp/CockMoveComp.cs

+ 7 - 6
Assets/Scripts/Comp/CockMoveComp.cs

@@ -13,14 +13,14 @@ namespace Comp
 
         private float _movingTime; // 水平运动时间
 
-        private const float MovingSpeed = 1f; // 移动速度
+        private const float MovingSpeed = 0.6f; // 移动速度
 
-        private const float MovingTime = 1f; // 移动时间
+        private const float MovingTime = 0.8f; // 移动时间
 
         // 跳跃相关
-        private const float HighJumpSpeed = 2f; // 高跳速度
+        private const float HighJumpSpeed = 3f; // 高跳速度
 
-        private const float LowJumpSpeed = 1f; // 低跳速度
+        private const float LowJumpSpeed = 2.5f; // 低跳速度
 
         private Vector3 CreateMovingVector(float speed)
         {
@@ -30,7 +30,7 @@ namespace Comp
 
         private Vector3 CreateJumpingVector(float y)
         {
-            return new Vector3(0, y, 0);
+            return Vector3.up * y;
         }
 
         public void Move()
@@ -55,7 +55,7 @@ namespace Comp
         {
             var jumpSpeed = highJump ? HighJumpSpeed : LowJumpSpeed;
             var jumpingVector = CreateJumpingVector(jumpSpeed);
-            _rigidbody.AddForce(jumpingVector); // 添加力
+            _rigidbody.AddForce(jumpingVector, ForceMode.Impulse); // 添加力
         }
 
         private void Start()
@@ -67,6 +67,7 @@ namespace Comp
         {
             if (!_isMoving) return;
             var movingVector = CreateMovingVector(MovingSpeed);
+            Debug.Log("moving vector is " + movingVector.x + ", " + movingVector.y + ", " + movingVector.z);
             transform.position += movingVector * Time.deltaTime;
             _movingTime -= Time.deltaTime;
             if (_movingTime <= 0)