当前位置: 首页>>代码示例>>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;未经允许,请勿转载。