本文整理汇总了C#中UnityEngine.Collider.GetComponentInParent方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetComponentInParent方法的具体用法?C# Collider.GetComponentInParent怎么用?C# Collider.GetComponentInParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider
的用法示例。
在下文中一共展示了Collider.GetComponentInParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter
private void OnTriggerEnter(Collider collider)
{
var handle = collider.GetComponentInParent<BowHandle>();
if (handle != null && obj != null && handle.aim.IsHeld() && obj.IsGrabbed())
{
handle.nockSide = collider.transform;
arrow.transform.parent = handle.arrowNockingPoint;
CopyNotchToArrow();
collider.GetComponentInParent<BowAim>().SetArrow(arrow);
Destroy(gameObject);
}
}
示例2: OnTriggerEnter
protected virtual void OnTriggerEnter(Collider collider)
{
Asteroid asteroid = collider.GetComponentInParent<Asteroid>();
if (!Paused)
TryCatchAsteroid(asteroid);
}
示例3: ToggleRigidbody
private void ToggleRigidbody(Collider collider, bool state)
{
var touch = collider.GetComponentInParent<VRTK_InteractTouch>();
if (touch)
{
touch.ToggleControllerRigidBody(state, state);
}
}
示例4: tryNotify
private void tryNotify(Collider other) {
IInteractionBehaviour ib = other.GetComponentInParent<IInteractionBehaviour>();
if (ib) {
manager.EnsureActive(ib);
_dislocatedCounter = 0;
ib.NotifyBrushDislocated();
}
}
示例5: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag == "Interactor")
{
switch (other.transform.parent.tag)
{
case "Customer":
Customer customer = other.GetComponentInParent<Customer>();
customer.OnInteract(this);
break;
case "Staff":
Staff staff = other.GetComponentInParent<Staff>();
staff.OnInteract(this);
break;
}
}
}
示例6: Change
private void Change(Collider target, bool targetValue)
{
if (target == null || !SmashGame.IsPlayer(target))
return;
var character = target.GetComponentInParent<Character>();
character.IsGrounded = targetValue;
}
示例7: 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;
}
}
示例8: Pickup
public void Pickup(Collider target)
{
// Check if target can be held
IPickupable held = (IPickupable)target.GetComponentInParent(typeof(IPickupable));
if (held != null)
{
hand.Pickup(held);
}
else
{
print("Not pickupable");
print(target.tag);
}
}
示例9: OnTriggerStay
public void OnTriggerStay(Collider a_other)
{
Rigidbody rigid = a_other.GetComponent<Rigidbody>();
if (rigid == null)
{
rigid = a_other.GetComponentInParent<Rigidbody>();
}
// Ensure that player has a rigidbody
if (rigid != null)
{
//This seems to be the best value for the time being- adjust this as necessary.
//rigid.velocity *= 0.985f;
rigid.velocity *= (delayFactor/2);
rigid.angularVelocity *= delayFactor; //-- Too much?
}
}
示例10: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player1_") || other.CompareTag("Player2_") || other.CompareTag("Player3_") || other.CompareTag("Player4_"))
{
ShipPartDestroy partScript = other.GetComponentInParent<ShipPartDestroy>();
if (partScript != null)
{
// Found in parent, repair
partScript.RepairAllParts();
}
else
{
// Look to children for the part object
partScript = other.GetComponentInChildren<ShipPartDestroy>();
if (partScript != null)
{
partScript.RepairAllParts();
}
}
}
}
示例11: OnTriggerEnter
void OnTriggerEnter(Collider col)
{
if (col.GetComponentInParent<BasePlayer>())
{
inTrigger.Add(col.GetComponentInParent<BasePlayer>());
OnEnterZone(this, col.GetComponentInParent<BasePlayer>());
}
}
示例12: Select
/// <summary>
/// Selects the given gameObject. A selected gameObject is followed and highlighted by a visual effect, and has its
/// statistics displayed on the UI.
/// </summary>
/// <param name="target">The gameObject to highlight</param>
void Select(Collider target)
{
// Check if the clicked thing is selectable
selected = (ISelectable)target.GetComponentInParent(typeof(ISelectable));
if (selected != null)
{
// Setting parent causes this object (and its children) to follow the parent
transform.parent = target.transform;
// This object floats just off the base of the selected object
transform.localPosition = new Vector3(0, 1.5f, 0);
// Turn on visual effects
visualEffect.SetActive(true);
selected.OnSelect();
}
}
示例13: OnTriggerExit
private void OnTriggerExit(Collider col)
{
//Interface.Oxide.LogInfo("Exit {0}: {1}", Info.ID, col.name);
var player = col.GetComponentInParent<BasePlayer>();
if (player != null)
{
if (!players.Remove(player)) return;
ZoneManagerPlugin.OnPlayerExitZone(this, player);
}
else if(!col.transform.CompareTag("MeshColliderBatch"))
CheckCollisionLeave(col);
else
{
var colliderBatch = col.GetComponent<MeshColliderBatch>();
if (colliderBatch != null)
{
var colliders = (ListDictionary<Component, ColliderCombineInstance>) InstancesField.GetValue(colliderBatch);
foreach (var instance in colliders.Values)
CheckCollisionLeave(instance.collider);
}
}
}
示例14: OnTriggerStay
public void OnTriggerStay(Collider other)
{
if (!IsAnimalAi(other))
{
return;
}
if (IsSelf(other))
{
return;
}
var direction = other.transform.position - gameObject.transform.position;
var angle = Vector3.Angle(direction, transform.forward);
if (angle < 0.5 * FieldOfViewAngle)
{
RaycastHit ray;
if (Physics.Raycast(transform.position, direction, out ray))
{
var otherAnimal = other.GetComponentInParent<AiRig>();
var collidedAnimal = ray.collider.GetComponentInParent<AiRig>();
if (collidedAnimal == otherAnimal)
{
ReportDetection(other);
return;
}
}
}
if (Detected.Contains(other))
{
ReportUndetection(other);
}
}
示例15: IsSelf
protected bool IsSelf(Collider other)
{
var components = GetComponentInParent(AiBase);
var otherAnimal = other.GetComponentInParent(AiBase);
return components == otherAnimal;
}