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


C# UnityEngine.Collision類代碼示例

本文整理匯總了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);
     }
 }
開發者ID:hardlydifficult,項目名稱:HardlyBot,代碼行數:7,代碼來源:Ball.cs

示例2: OnCollisionEnter

 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag.Equals(tagType)) {
         Destroy(col.gameObject);
         Destroy(gameObject);
     }
 }
開發者ID:blackstrings,項目名稱:knife,代碼行數:7,代碼來源:Bullet.cs

示例3: OnCollisionEnter

				void OnCollisionEnter (Collision collision)
				{
						if (TargetValidator != null && !TargetValidator.Test (collision.gameObject))
								return;

						BoolValue = true;
				}
開發者ID:ryanwang,項目名稱:VR-Planetarium,代碼行數:7,代碼來源:CollissionEmitter.cs

示例4: OnCollisionStay

 void OnCollisionStay(Collision collision)
 {
     if (collision.gameObject && collision.gameObject.tag == "Hero")
     {
         eventCollistionStayHero(this, collision.gameObject.GetComponent<Hero>());
     }
 }
開發者ID:sidan93,項目名稱:revival_the_game,代碼行數:7,代碼來源:BaseMonster.cs

示例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);
         }
     }
 }
開發者ID:kevin-ye,項目名稱:hangar,代碼行數:34,代碼來源:ModuleWheelDebug.cs

示例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;
     }
 }
開發者ID:wishes2018,項目名稱:UnityGame,代碼行數:7,代碼來源:HasExitedCollision.cs

示例7: OnCollisionStay

 void OnCollisionStay(Collision aCollision)
 {
     if(m_Character != null)
     {
     m_Character.OnCollisionStay(aCollision);
     }
 }
開發者ID:NathanSaidas,項目名稱:OnLooker_Unity,代碼行數:7,代碼來源:CharacterCollisionHandler.cs

示例8: DoCollisionStay

 public override void DoCollisionStay(Collision collisionInfo)
 {
     if (this.runFsm.HandleCollisionStay)
     {
         this.runFsm.OnCollisionStay(collisionInfo);
     }
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:7,代碼來源:RunFSM.cs

示例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;
			}
		}
開發者ID:paulkelly,項目名稱:GGJ2016,代碼行數:8,代碼來源:PlatformRotator.cs

示例10: CollisionNodeInfo

 public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
 {
     this.hitNode = hitNode;
     collider = colliderObj;
     collision = collisionObj;
     controllerColliderHit = cchit;
 }
開發者ID:WaylandGod,項目名稱:EasyMotion2D.Runtime,代碼行數:7,代碼來源:CollisionNodeToggler.cs

示例11: DoCollisionExit

 public override void DoCollisionExit(Collision collisionInfo)
 {
     if (this.runFsm.HandleCollisionExit)
     {
         this.runFsm.OnCollisionExit(collisionInfo);
     }
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:7,代碼來源:RunFSM.cs

示例12: OnCollisionEnter

 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject == destroyGoal)
     {
         Destroy(gameObject);
     }
 }
開發者ID:Iconiac,項目名稱:EXODUS,代碼行數:7,代碼來源:ParentMove.cs

示例13: OnCollisionEnter

 void OnCollisionEnter(Collision coll)
 {
     if(coll.collider.tag == "Player" && !Pressed && !done)
     {
         Press();
     }
 }
開發者ID:Dawnwoodgames,項目名稱:LotsOfTowers,代碼行數:7,代碼來源:MemoryStep.cs

示例14: DoCollisionEnter

 public override void DoCollisionEnter(Collision collisionInfo)
 {
     if (runFsm.HandleCollisionEnter)
     {
         runFsm.OnCollisionEnter(collisionInfo);
     }
 }
開發者ID:trondtrond,項目名稱:PlayMaker--Unity--UI,代碼行數:7,代碼來源:RunTemplateFSM.cs

示例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);
                }
            }
        }
開發者ID:cupsster,項目名稱:ExtremeBusiness,代碼行數:35,代碼來源:FractureOnCollision.cs


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