当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.Collider类代码示例

本文整理汇总了C#中UnityEngine.Collider的典型用法代码示例。如果您正苦于以下问题:C# Collider类的具体用法?C# Collider怎么用?C# Collider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Collider类属于UnityEngine命名空间,在下文中一共展示了Collider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerExit

 public void OnTriggerExit(Collider other)
 {
     if (list.Contains(other.gameObject))
     {
         list.Remove(other.gameObject);
     }
 }
开发者ID:dafei2015,项目名称:LOLClient,代码行数:7,代码来源:Eye.cs

示例2: OnTriggerEnter

        private void OnTriggerEnter(Collider col)
        {
            Destructible destObj = col.gameObject.GetComponentInParent<Destructible>();

            // If it has a rigidbody, apply force
            Rigidbody rbody = col.attachedRigidbody;
            if (rbody != null && !rbody.isKinematic)
                rbody.AddExplosionForce(blastForce, origin, 0f, 0.5f);

            // Check for Chip-Away Debris
            ChipAwayDebris chipAwayDebris = col.gameObject.GetComponent<ChipAwayDebris>();
            if (chipAwayDebris != null)
            {
                if (UnityEngine.Random.Range(1, 100) > 50) // Do this about half the time...
                {
                    chipAwayDebris.BreakOff(blastForce, origin, 0f, 0.5f);
                    return; //Skip the destructible check if the debris hasn't chipped away yet.
                }
                else
                    return;
            }

            // If it's a destructible object, apply damage
            if (destObj != null)
            {
                destObj.ApplyExplosiveDamage(new ExplosionInfo()
                {
                    BlastForce = blastForce,
                    Position = origin,
                    Radius = 0f,
                    UpwardModifier = 0.5f
                });
            }
        }
开发者ID:tegleg,项目名称:mfp,代码行数:34,代码来源:ShockWall.cs

示例3: OnTriggerEnter

 void OnTriggerEnter(Collider col)
 {
     if (col.tag == "Fire")
     {
         hasFireContact = true;
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:7,代码来源:FireWood.cs

示例4: OnTriggerEnter

 public override void OnTriggerEnter(Collider collider)
 {
     if(collider.gameObject.GetComponent<UnitPlayer>()!=null){
         GameControl.GameOver(true);
         Triggered();
     }
 }
开发者ID:NDGAME,项目名称:Git_test,代码行数:7,代码来源:TriggerPlayer_Win.cs

示例5: OnTriggerExit

		void OnTriggerExit (Collider other)
		{
			if (other.gameObject == player) 
			{
				shouldDamage = false;
			}
		}
开发者ID:Gianni89,项目名称:survivalshooter,代码行数:7,代码来源:SplatDamage.cs

示例6: OnTriggerEnter

 public void OnTriggerEnter(Collider other)
 {
     explosionEmitter.Emit(200);
     volumeController.Stop();
     mGameOver = true;
     Invoke ("StartOver", 1);
 }
开发者ID:scumbly,项目名称:Organ-Grinder,代码行数:7,代码来源:VolumeControllerInput.cs

示例7: OnTriggerEnter

 void OnTriggerEnter(Collider coll)
 {
     if (coll.gameObject.tag == "Player")
     {
         inTrigger = true;
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:7,代码来源:OpenDoorLever.cs

示例8: OnTriggerEnter

 // OnTriggerEnter is called when the agent runs into a trigger that specifies what task to run text
 public override void OnTriggerEnter(Collider other)
 {
     TriggerType triggerType = null;
     if ((triggerType = other.GetComponent<TriggerType>()) != null) {
         nextTaskIndex = (int)triggerType.triggerType;
     }
 }
开发者ID:JohnnyVox,项目名称:schoolfire,代码行数:8,代码来源:TaskTriggerSelector.cs

示例9: ProcessWeaponCollision

        protected virtual void ProcessWeaponCollision(Collider collider, Vector3 dir, Vector3 hitPoint)
        {
            Vector3 direction = -dir * hitForce;

            MonsterController monsterController = collider.transform.GetComponentInParent<MonsterController>();
            if (monsterController != null)
            {
                target = monsterController.gameObject;
                // targetRigidbody = target.GetComponent<Rigidbody>();
                monsterController.Hit(collider,direction, hitPoint, damage);
            }


            int effectNum;
            if (effects == null)
            {
                effectNum = 0;
            }
            else
            {
                effectNum = effects.Length;
            }
            if (effectNum > 0)
            {
                int eindex = Random.Range(0, effectNum);
                GameObject go = (GameObject)GameObject.Instantiate(effects[eindex], hitPoint, Quaternion.identity);
                Object.Destroy(go, 1);
            }
        }
开发者ID:pangaeastudio,项目名称:vrgame-bruceli,代码行数:29,代码来源:HitTrigger.cs

示例10: OnTriggerStay

 private void OnTriggerStay( Collider other ) {
     if ( other.tag != SRTags.Ball ) { return; }
     Vector3 direction = other.transform.position - transform.position;
     Debug.DrawLine( transform.position, transform.position + direction );
     float force = ForceStrength * CalculateForceMultiplier( direction.magnitude ) * (int)Mode;
     other.attachedRigidbody.AddForce( direction * force );
 }
开发者ID:Godofdrakes,项目名称:Impossible-Pinball,代码行数:7,代码来源:FlowField.cs

示例11: 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;
    }
开发者ID:MaTriXy,项目名称:cardboard-unity,代码行数:27,代码来源:RaquetBouncer.cs

示例12: SphereCastProvider

        public SphereCastProvider(Collider c)
        {
            Ensure.ArgumentNotNull(c, "c");

            var t = c.transform;
            var scale = t.lossyScale;

            var sc = c as SphereCollider;
            var cc = c as CapsuleCollider;
            if (sc != null)
            {
                var scaling = Mathf.Max(scale.x, scale.y, scale.z);
                _radius = sc.radius * scaling;
                _centerOffsetY = sc.center.y * scaling;
            }
            else if (cc != null && cc.direction == 1)
            {
                _radius = cc.radius * Mathf.Max(scale.x, scale.z);
                _centerOffsetY = (cc.center.y * scale.y) - Mathf.Max((cc.height * scale.y * 0.5f) - _radius, 0f);
            }
            else
            {
                throw new ArgumentException("A sphere cast provider only works with sphere or vertical capsule colliders!");
            }
        }
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:25,代码来源:SphereCastProvider.cs

示例13: OnTriggerEnter

        void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.CompareTag ("Pick Up"))
            {

                audioSource.PlayOneShot(audioCollect);
                other.gameObject.SetActive (false);
                ScoreManager.score += scoreValue;

            }

            else if (other.gameObject.CompareTag ("HpItem"))
            {
                audioSource.PlayOneShot (audioCollect);
                other.gameObject.SetActive (false);
                playerHealth.Recovery(healthPoint);

            }

            else if (other.gameObject.CompareTag ("ExpItem"))
            {
                audioSource.PlayOneShot (audioCollect);
                other.gameObject.SetActive (false);
                playerLevel.ExpUpItem(expPoint);
            }
        }
开发者ID:enro92,项目名称:Unity,代码行数:26,代码来源:PlayerCollectItem.cs

示例14: SetHeadsetCollisionEvent

 protected HeadsetCollisionEventArgs SetHeadsetCollisionEvent(Collider collider, Transform currentTransform)
 {
     HeadsetCollisionEventArgs e;
     e.collider = collider;
     e.currentTransform = currentTransform;
     return e;
 }
开发者ID:yanzhao571,项目名称:SteamVR_Unity_Toolkit,代码行数:7,代码来源:VRTK_HeadsetCollisionFade.cs

示例15: OnTriggerEnter

	    void OnTriggerEnter(Collider other) 
		{	
			if(!sequenceToPlay)
			{
				Debug.LogWarning("You have triggered a sequence in your scene, however, you didn't assign it a Sequence To Play", gameObject);
				return;
			}
			
			if(sequenceToPlay.IsPlaying)
				return;
			
			if(other.CompareTag("MainCamera") && isMainCameraTrigger)
			{
				sequenceToPlay.Play();
				return;
			}
			
			if(other.CompareTag("Player") && isPlayerTrigger)
			{
				sequenceToPlay.Play();
				return;
			}
			
			if(other.gameObject == triggerObject)
			{
				sequenceToPlay.Play();
				return;
			}
		}
开发者ID:totoro-j,项目名称:BallSpy,代码行数:29,代码来源:SequenceTrigger.cs


注:本文中的UnityEngine.Collider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。