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