0
    public float tilt =-5f;
    public float horizontal;
    public float vertical;
    Rigidbody player;
    void Start()
    {
            
        player = GetComponent<Rigidbody>();
            
       }
        void Update()
        {
           
    
            player.velocity = new Vector3(horizontal, vertical, 7f);
    
            var clamX = Mathf.Clamp(player.position.x, xmin, xmax);
            var clamY = Mathf.Clamp(player.position.y, ymin, ymax);
            player.position = new Vector3(clamX, clamY, player.position.z);
            player.rotation = Quaternion.Euler(vertical*tilt,0, horizontal * tilt);
    
    
        }
//turn on the left
     public void Onleft()
        {
           
            horizontal = -7f;
        }
//turn on the right
        public void OnRigth()
        {
            
            horizontal = 7f;
        }
      public void Up()
      {
           
            horizontal = 0f;



      

} // 我在按钮上加了一个事件触发器,当然也给这个事件加了一些函数:OnLeft(),OnRight(),但是加了按钮后船的转弯角度变得非常快,如何解决船的旋转角度,当向左或向右按​​下按钮时,是否有点平滑?

4

1 回答 1

0

好吧,平滑和较慢之间是有区别的。

要实现较慢的旋转,只需将旋转值乘以另一个值。

rotationValue = 10;
speed = 1/2;
//newRotationValue 
rotationValue *= speed; //5;

但是如果你想平滑你的运动过渡/旋转,我强烈建议你使用Lerp,更具体地说,当你使用旋转时,Quaternion.Lerp

Lerp 将使您的旋转在两点(您的开始旋转和最终旋转)之间进行线性插值并标准化结果,因此它看起来更“平滑”。

于 2020-10-09T10:24:38.500 回答