本文整理汇总了C#中UnityEngine.Collision类的典型用法代码示例。如果您正苦于以下问题:C# Collision类的具体用法?C# Collision怎么用?C# Collision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collision类属于UnityEngine命名空间,在下文中一共展示了Collision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
var weHit = col.gameObject;
if(weHit.tag.Equals("Pickupable")) {
weHit.transform.position = new Vector3(weHit.transform.position.x, 100, weHit.transform.position.z);
}
}
示例2: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag.Equals(tagType)) {
Destroy(col.gameObject);
Destroy(gameObject);
}
}
示例3: OnCollisionEnter
void OnCollisionEnter (Collision collision)
{
if (TargetValidator != null && !TargetValidator.Test (collision.gameObject))
return;
BoolValue = true;
}
示例4: OnCollisionStay
void OnCollisionStay(Collision collision)
{
if (collision.gameObject && collision.gameObject.tag == "Hero")
{
eventCollistionStayHero(this, collision.gameObject.GetComponent<Hero>());
}
}
示例5: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
Utils.Log("Collision detected with {0}", collision.gameObject.name);
Utils.Log("Collider is {0}", collision.collider);
foreach(ContactPoint c in collision.contacts)
{
Utils.Log("Contact point: this collider {0}; other collider {1}", c.thisCollider, c.otherCollider);
Utils.Log("other collider tag: {0}", c.otherCollider.tag);
Utils.Log("Other pmat: bounce {0}, dynFric {1}, statFric {2}",
c.otherCollider.material.bounciness,
c.otherCollider.material.dynamicFriction,
c.otherCollider.material.staticFriction);
Utils.Log("Other pmat: bounce-comb {0}, Fric-comb {1}, dynFric2 {2}, statFric2 {3}, FricDir2 {4}",
c.otherCollider.material.bounceCombine,
c.otherCollider.material.frictionCombine,
c.otherCollider.material.dynamicFriction2,
c.otherCollider.material.staticFriction2,
c.otherCollider.material.frictionDirection2);
foreach(Wheel w in wheels)
{
Utils.Log("Wheel {0}", w.wheelName);
Utils.Log("forwardFriction.stiffness {0}, sidewaysFriction.stiffness {1}",
w.whCollider.forwardFriction.stiffness, w.whCollider.sidewaysFriction.stiffness);
Utils.Log("forwardFriction.asymptote {0}, sidewaysFriction.asymptote {1}",
w.whCollider.forwardFriction.asymptoteValue, w.whCollider.sidewaysFriction.asymptoteValue);
Utils.Log("forwardFriction.a-slip {0}, sidewaysFriction.a-slip {1}",
w.whCollider.forwardFriction.asymptoteSlip, w.whCollider.sidewaysFriction.asymptoteSlip);
Utils.Log("forwardFriction.extremum {0}, sidewaysFriction.extremum {1}",
w.whCollider.forwardFriction.extremumValue, w.whCollider.sidewaysFriction.extremumValue);
Utils.Log("forwardFriction.e-slip {0}, sidewaysFriction.e-slip {1}",
w.whCollider.forwardFriction.extremumSlip, w.whCollider.sidewaysFriction.extremumSlip);
}
}
}
示例6: OnCollisionExit
public override void OnCollisionExit(Collision collision)
{
if (string.IsNullOrEmpty(tag.Value) || tag.Value.Equals(collision.gameObject.tag)) {
collidedGameObject.Value = collision.gameObject;
exitedCollision = true;
}
}
示例7: OnCollisionStay
void OnCollisionStay(Collision aCollision)
{
if(m_Character != null)
{
m_Character.OnCollisionStay(aCollision);
}
}
示例8: DoCollisionStay
public override void DoCollisionStay(Collision collisionInfo)
{
if (this.runFsm.HandleCollisionStay)
{
this.runFsm.OnCollisionStay(collisionInfo);
}
}
示例9: OnCollisionExit
// Re-enable fixed time step smoothing on the characters that exited this platform
void OnCollisionExit(Collision collision) {
if (collision.gameObject.layer == characterLayer) {
CharacterThirdPerson c = collision.gameObject.GetComponent<CharacterThirdPerson>();
if (c == null) return;
c.smoothPhysics = true;
}
}
示例10: CollisionNodeInfo
public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
{
this.hitNode = hitNode;
collider = colliderObj;
collision = collisionObj;
controllerColliderHit = cchit;
}
示例11: DoCollisionExit
public override void DoCollisionExit(Collision collisionInfo)
{
if (this.runFsm.HandleCollisionExit)
{
this.runFsm.OnCollisionExit(collisionInfo);
}
}
示例12: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject == destroyGoal)
{
Destroy(gameObject);
}
}
示例13: OnCollisionEnter
void OnCollisionEnter(Collision coll)
{
if(coll.collider.tag == "Player" && !Pressed && !done)
{
Press();
}
}
示例14: DoCollisionEnter
public override void DoCollisionEnter(Collision collisionInfo)
{
if (runFsm.HandleCollisionEnter)
{
runFsm.OnCollisionEnter(collisionInfo);
}
}
示例15: OnCollisionEnter
private void OnCollisionEnter(Collision col)
{
if (col.contacts.Length > 0)
{
_impactBody = col.rigidbody;
_impactMass = (col.rigidbody != null) ? col.rigidbody.mass : 1.0f;
_impactVelocity = col.relativeVelocity;
Rigidbody rb = GetComponent<Rigidbody>();
if (rb != null)
{
// Always have the impact velocity point in our moving direction
_impactVelocity *= Mathf.Sign(Vector3.Dot(rb.velocity, _impactVelocity));
}
float mag = _impactVelocity.magnitude;
Vector3 force = 0.5f * _impactMass * _impactVelocity * mag;
if ((ForceThreshold * ForceThreshold) <=
force.sqrMagnitude)
{
_impactPoint = Vector3.zero;
for (int i = 0; i < col.contacts.Length; i++)
{
_impactPoint += col.contacts[i].point;
}
_impactPoint *= 1.0f / col.contacts.Length;
Vector3 localPoint = transform.worldToLocalMatrix.MultiplyPoint(_impactPoint);
GetComponent<FractureGeometry>().Fracture(localPoint);
}
}
}