球员的圆周运动

时间:2014-12-22 08:00:38

标签: unity3d

我有一个鲨鱼作为玩家对象,我试图用脚本来控制,当我按下一个键时,鲨鱼会随着动画一起向所需的方向移动。

脚本工作正常,除非我用它以圆周运动向左转。然而,同样不能给出期望的运动,因为旋转在同一圆圈中是顺时针方向或反时钟方式。

我要做的是当我按下右侧移动键时,鲨鱼应该从最后一个位置以圆周运动向右侧移动。这是脚本..非常感谢这里的任何帮助。

using UnityEngine;
using System.Collections;

public class PredatorSphereScript : MonoBehaviour
{
private float m_moveSpeed = 50.0f;

    void Start()
    {

    }

    void FixedUpdate ()
{

        if (Input.GetKey("j"))
        {
            moveLeft();
        }
        else if (Input.GetKeyUp("j"))
        {
            moveSlow();
        }
        if (Input.GetKey("l"))
        {
            moveRight();
        }
        else if (Input.GetKeyUp("l"))
        {
            moveSlow();
        }
     }


    public void moveLeft()
    {
         trtransform.Rotate (Vector3.down * Time.deltaTime * -m_moveSpeed);
        {
            animation.CrossFade("SharkLT", 0.2f);
        }
    }

    public void moveRight()
    {
           transform.Rotate (Vector3.down * Time.deltaTime * m_moveSpeed);
        {
            animation.CrossFade("SharkRT", 0.2f);
        }
    }

}

0 个答案:

没有答案
相关问题