本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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>());
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
}
示例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;
}
}
}
示例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);
}
}