本文整理汇总了C#中UnityEngine.Collider.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.Equals方法的具体用法?C# Collider.Equals怎么用?C# Collider.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider
的用法示例。
在下文中一共展示了Collider.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
void OnTriggerEnter(Collider collider) {
Rigidbody otherRigidbody = collider.attachedRigidbody;
if (otherRigidbody == null || collider.Equals(justHit) || !collider.CompareTag("TennisBall")) {
return;
}
justHit = collider;
justHitCooldown = .5f;
bool forehandBackhand = (new Plane(transform.up, transform.position)).GetSide(transform.position + velocityVector);
Vector3 raquetNormal = forehandBackhand ? transform.up : transform.up * -1;
Vector3 reflectedVec = Vector3.zero;
if (velocityVector.magnitude < 1f) {
reflectedVec = Vector3.Reflect(otherRigidbody.velocity, raquetNormal);
} else {
Vector3 vel = otherRigidbody.velocity.normalized;
Vector3 reflectedBallVel = new Vector3(vel.x, -vel.y, -vel.z);
reflectedVec = (reflectedBallVel + raquetNormal * RaquetAnglePriority) / (RaquetAnglePriority + 1);
}
otherRigidbody.velocity = Vector3.ClampMagnitude((reflectedVec * (1 + velocityVector.magnitude)) * Bounciness, MaxHitSpeed);
RaquetAudioSource.volume = Mathf.Min(Mathf.Pow(otherRigidbody.velocity.magnitude / 5f, 5f), 1f);
RaquetAudioSource.Play();
TrailRenderer trail = collider.GetComponent<TrailRenderer>();
trail.enabled = true;
}