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


C# Collider.GetComponent方法代码示例

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


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

示例1: OnTriggerEnter

 void OnTriggerEnter(Collider hit)
 {
     if(hit.GetComponent<ROBgui>()) {
         hit.GetComponent<ROBgui>().messageSet(text);
         Destroy(this.gameObject);
     }
 }
开发者ID:spooty89,项目名称:Project-ROB,代码行数:7,代码来源:UpdateMessage.cs

示例2: OnTriggerEnter

 void OnTriggerEnter(Collider _col)
 {
     if(_isColliding) return;
     _isColliding = true;
     if(_col.tag.Equals("Player")) _col.GetComponent<Player.PlayerMove>().Slip(this.transform.forward);
     else if(_col.tag.Equals("Pickup")) _col.GetComponent<Player.ObjectSlider>().Slide(this.transform.forward);
 }
开发者ID:sabrinagreenlee,项目名称:JaneBound,代码行数:7,代码来源:SlipperyArea.cs

示例3: OnTriggerStay

 void OnTriggerStay(Collider other)
 {
     if (!targetsBurning.Contains(other.gameObject.GetInstanceID()) && other.GetComponent<LivingEntity>() && other.tag != "Player")
     {
         targetsBurning.Add(other.gameObject.GetInstanceID());
         other.GetComponent<LivingEntity>().TakeDirectDamage(DoDamage());
         Debug.Log(other.tag);
     }
 }
开发者ID:x9litch,项目名称:ProjectJanitor,代码行数:9,代码来源:FlameController.cs

示例4: OnTriggerStay

 private void OnTriggerStay(Collider collider)
 {
     var controller = (collider.GetComponent<VRTK_ControllerEvents>() ? collider.GetComponent<VRTK_ControllerEvents>() : collider.GetComponentInParent<VRTK_ControllerEvents>());
     if (controller)
     {
         if (lastUsePressedState == true && !controller.usePressed)
         {
             var distance = Vector3.Distance(transform.position, destination.position);
             var controllerIndex = VRTK_DeviceFinder.GetControllerIndex(controller.gameObject);
             OnDestinationMarkerSet(SetDestinationMarkerEvent(distance, destination, new RaycastHit(), destination.position, controllerIndex));
         }
         lastUsePressedState = controller.usePressed;
     }
 }
开发者ID:MechroCat22,项目名称:VR-Object-Hunt,代码行数:14,代码来源:ModelVillage_TeleportLocation.cs

示例5: OnTriggerEnter

 public void OnTriggerEnter(Collider other)
 {
     if(other.gameObject.layer == layerPickup) {
         PickupCargo(other.GetComponent<CargoPickup>());
     }
     if(other.gameObject.layer == layerCity) {
         TryDropoff(other.GetComponent<City>());
     }
 }
开发者ID:Beanalby,项目名称:1GameAMonth14,代码行数:9,代码来源:TrainContainer.cs

示例6: OnTriggerStay

 void OnTriggerStay(Collider aOther)
 {
     if (!m_isActive) return;
     if (aOther.GetComponent<PhotonView>() != null && aOther.GetComponent<PhotonView>().owner == PhotonNetwork.player)
     {
         GameObject.Find("GameManager").GetComponent<GameManager>().BombPickedUp(aOther.GetComponent<PhotonView>().owner, m_pickupID);
         m_isActive = false;
         Destroy(gameObject);
     }
 }
开发者ID:Vince-Bitheads,项目名称:UnityExamples,代码行数:10,代码来源:BombPickup.cs

示例7: OnTriggerStay

 void OnTriggerStay(Collider aOther)
 {
     if (!m_isActive) return;
     if (aOther.GetComponent<PlaneController>() != null && aOther.GetComponent<PlaneController>().m_playerID == BombersNetworkManager.m_localPlayer.m_playerID)
     {
         BombersNetworkManager.m_localPlayer.BombPickedUpCommand(BombersNetworkManager.m_localPlayer.m_playerID, m_pickupID);
         m_isActive = false;
         Destroy(gameObject);
     }
 }
开发者ID:Vince-Bitheads,项目名称:UnityExamples,代码行数:10,代码来源:BombPickup.cs

示例8: OnTriggerExit

 void OnTriggerExit(Collider coll)
 {
     if (coll.tag == "Player")
     {
         libra.GetComponent<LibraTrigger>().playerReadyToLaunch = false;
         coll.GetComponent<Rigidbody>().mass = 1;
         coll.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
         GameObject.Find("Level").GetComponent<Level.LevelOne>().ModifySpawnPoint();
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:10,代码来源:JumpTrigger.cs

示例9: interception

 private void interception(Collider ballCollider)
 {
     // ramasse/intercepte la balle uniquement si le perso a au moins un élément "passe"
     if (ballCollider.transform.parent == null && ballCollider.name == "Ball" && player.Passe != 0 && ballCollider.GetComponent<BallController>().interceptable(gameObject))
     {
         ballCollider.transform.parent = transform.FindChild("perso").transform;
         ballCollider.GetComponent<Collider>().enabled = false;
         ballCollider.transform.localPosition = new Vector3(1.3f, 3, 0);
     }
 }
开发者ID:CanPayU,项目名称:SuperSwungBall,代码行数:10,代码来源:CollisionController.cs

示例10: OnTriggerEnter

 private void OnTriggerEnter(Collider coll)
 {
     if (coll.tag == "Player")
     {
         regularMass = coll.GetComponent<Rigidbody>().mass;
         player = coll.gameObject;
         playerOnLibra = true;
         coll.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
         libra.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.None;
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:11,代码来源:LibraTrigger.cs

示例11: OnTriggerStay

        //---------------------------- While the Umbrella is off the island ---------------------------------------//
        void OnTriggerStay(Collider barrier)
        {
            if (barrier.tag == "Player") {

                _timer += Time.deltaTime;
                barrier.GetComponent<Rigidbody> ().drag = Mathf.Lerp (barrier.GetComponent<Rigidbody> ().drag, 10, Time.fixedDeltaTime / 100);
                if (_timer > 3) {
                    barrier.GetComponent<Rigidbody> ().AddForce (knockBack * directionOfForce);
                }
            }
        }
开发者ID:HumfreeTickle,项目名称:MSC_UmbrellaGame,代码行数:12,代码来源:Barriers.cs

示例12: OnTriggerEnter

 //Check which object collide with the wind capsule
 void OnTriggerEnter(Collider col)
 {
     // Add the GameObject collided with to the list.
     if (col.GetComponent<Rigidbody>())
     {
         if (!col.GetComponent<Rigidbody>().isKinematic)
         {
             currentCollisions.Add(col.gameObject);
         }
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:12,代码来源:WindTrigger.cs

示例13: OnTriggerEnter

 void OnTriggerEnter(Collider coll)
 {
     if (coll.tag == "Fracture")
     {
         coll.transform.position = gameObject.transform.position;
         coll.transform.rotation = new Quaternion(0, 0, 0, 0);
         coll.GetComponent<Rigidbody>().isKinematic = true;
         coll.GetComponent<Renderer>().material.SetColor("_Color", Color.white);
         coll.GetComponent<InteractableObjectOutline>().enabled = false;
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:11,代码来源:FractureSnapTrigger.cs

示例14: OnTriggerStay

 void OnTriggerStay(Collider coll)
 {
     if (coll.tag == "Player" && Input.GetButtonDown("Submit"))
     {
         if (!complete && coll.GetComponent<Player>().HoldingWater && coll.GetComponent<Player>().Onesie.isHeavy)
         {
             coll.GetComponent<Player>().HoldingWater = false;
             waterGiven = true;
         }
     }
 }
开发者ID:Dawnwoodgames,项目名称:LotsOfTowers,代码行数:11,代码来源:PlaceIceBlock.cs

示例15: OnTriggerStay

        void OnTriggerStay(Collider other)
        {
            if (other.gameObject.tag == "Player") {
                if (other.GetComponent<Rigidbody> ()) {
                    other.GetComponent<Rigidbody> ().AddForce (transform.forward * push);

                }
                umbrellaAnim.SetBool ("Hit", true);

                push -= 1;
                push = Mathf.Clamp (push, 0, savedPush);

            }
        }
开发者ID:HumfreeTickle,项目名称:MSC_UmbrellaGame,代码行数:14,代码来源:ChimneyBlow.cs


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