本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}