當前位置: 首頁>>代碼示例>>C#>>正文


C# Quaternion.Set方法代碼示例

本文整理匯總了C#中UnityEngine.Quaternion.Set方法的典型用法代碼示例。如果您正苦於以下問題:C# Quaternion.Set方法的具體用法?C# Quaternion.Set怎麽用?C# Quaternion.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Quaternion的用法示例。


在下文中一共展示了Quaternion.Set方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CalculateDecay

    /// <summary>
    /// decays rotation , 
    /// </summary>
    /// <param name="q"></param>
    /// <param name="decayRate"></param> 0 == instant decay
    /// <returns></returns>
    private Quaternion CalculateDecay( Quaternion q, float decayRate = 0.99f)
    {
        if (decayRate == 0)
            return new Quaternion(0, 0, 0, 1);

        q.Set(q.x * decayRate, q.y * decayRate, q.z * decayRate, q.w * 1 / decayRate);
        return q;
    }
開發者ID:TamaHobbit,項目名稱:DMV,代碼行數:14,代碼來源:Controller_SpaceShip.cs

示例2: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     //Debug.Log("waterCollision");
     Quaternion p = new Quaternion();
     p.Set (0.0f, 0.0f, 0.0f, 0.0f);
     ParticleSystem tmp = Instantiate(splashOriginal, other.gameObject.transform.position,p) as ParticleSystem;
     tmp.gameObject.transform.Rotate(q.x,q.y,q.z);
     Destroy (tmp.gameObject, cleanPeriod);
 }
開發者ID:Morthalin,項目名稱:TheGame,代碼行數:9,代碼來源:splashOnCollision.cs

示例3: Update

	// Update is called once per frame
	void Update () {

        float xForce =0, yForce=0, zForce = 0;
        float rotationForce = 0.08f * Time.deltaTime;
        //float angularDecayRate = 0.99f;
        bool buttonpressed = false;

        Quaternion addedAngular = new Quaternion();
        
        // pan/yaw controls
        if (Input.GetKey(KeyCode.A))
        {
            zForce = rotationForce;
            buttonpressed = true;
        }
        if (Input.GetKey(KeyCode.D))
        {
            zForce = -rotationForce;
            buttonpressed = true;
        }

        // roll
        if (Input.GetKey(KeyCode.Q))
        {
            yForce = rotationForce;
            buttonpressed = true;
        }
        if (Input.GetKey(KeyCode.E))
        {
            yForce = -rotationForce;
            buttonpressed = true;
        }

        // Pitch
        if (Input.GetKey(KeyCode.W))
        {
            xForce = rotationForce;
            buttonpressed = true;
        }
        if (Input.GetKey(KeyCode.S))
        {
            xForce = -rotationForce;
            buttonpressed = true;
        }
        if (buttonpressed)
            buttonpressed = !!buttonpressed;

        addedAngular.Set(xForce, yForce, zForce, 1);
        //AngularVelocity *= addedAngular; // add angular velocity using added force 

        AngularVelocity *= addedAngular;
        transform.rotation *= AngularVelocity; // apply total angular to rotation

        AngularVelocity = CalculateDecay(AngularVelocity);
    }
開發者ID:TamaHobbit,項目名稱:DMV,代碼行數:56,代碼來源:Controller_SpaceShip.cs

示例4: Start

    void Start()
    {
        begin = transform.localRotation;
        end = begin;
        maxTime = degrees / speed;
        origTimeTilStop = timeTilStop;

        if (axis == 'x')
            end.Set(begin.x + degrees, begin.y, begin.z, begin.w);
        else if (axis == 'y')
            end.Set(begin.x, begin.y + degrees, begin.z, begin.w);
        else if (axis == 'z')
            end.Set(begin.x, begin.y, begin.z + degrees, begin.w);
        else if (axis == 'w')
            end.Set(begin.x, begin.y, begin.z, begin.w + degrees);

        mesh = transform.GetComponentInChildren<MeshRenderer>();

        Debug.Log("Begin: " + begin + " End: " + end);
    }
開發者ID:Vwing,項目名稱:Breakout,代碼行數:20,代碼來源:RotateSlerp.cs

示例5: NormaliseQuat

 public static void NormaliseQuat(ref Quaternion q)
 {
     float norm = Mathf.Sqrt(Mathf.Pow(q.x, 2) + Mathf.Pow(q.y, 2) + Mathf.Pow(q.z, 2) + Mathf.Pow(q.w, 2));
     q.Set(q.x / norm, q.y / norm, q.z / norm, q.w / norm);
 }
開發者ID:HASParty,項目名稱:ggpai,代碼行數:5,代碼來源:IKMath.cs


注:本文中的UnityEngine.Quaternion.Set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。