private void OnTriggerEnter(UnityEngine.Collider other) { if (other.gameObject.tag == "Bullet" || other.gameObject.tag == "Object") { Destroy(other); } }
void OnTriggerExit (Collider other) { if (other.gameObject == player) { shouldDamage = false; } }
/// <summary> /// Only guaranteed to be correct for convex colliders. /// </summary> public bool CollidesWith(UnityEngine.Collider unityCollider, bool includeBehindPlane = false) { var planePose = this.pose; var planePoseInverse = this.pose.inverse(); var colliderCenter = getUnityColliderWorldCenter(unityCollider); var colliderCenter_plane = planePoseInverse.mul(colliderCenter).position; var colliderCenterOnPlane_plane = colliderCenter_plane.WithZ(0f); var colliderCenterOnPlane = planePose.mul(colliderCenterOnPlane_plane).position; var closestPoint = unityCollider.ClosestPoint(colliderCenterOnPlane); var closestPoint_plane = planePoseInverse.mul(closestPoint).position; // Concave shapes will break here; projection from their center is not // valid. To support concavity, you'd want to project to the plane from // the planeward-most point on the concave collider. var planeToClosestPoint_plane = closestPoint_plane - colliderCenterOnPlane_plane; if (includeBehindPlane) { // Plane faces forward on Z. return(planeToClosestPoint_plane.z <= 0f); } else { return(planeToClosestPoint_plane.z == 0f); } }
/// <summary> /// Attempts to calculate geometry for a collider. Not tested yet. /// </summary> /// <param name="c"></param> /// <returns></returns> public static IGeom GetColliderGeom(Collider c) { if(c == null) return null; if (c is CharacterController) { return Capsule.FromCollider(c as CharacterController); } if (c is CapsuleCollider) { return Capsule.FromCollider(c as CapsuleCollider); } else if (c is BoxCollider) { //TODO - implement Box Geom return new AABBox(c.bounds); } else if (c is SphereCollider) { return Sphere.FromCollider(c as SphereCollider); } else { //otherwise just return bounds as AABBox return new AABBox(c.bounds); } }
void OnTriggerExit(Collider coll) { if (coll.gameObject.tag == "Player") { inTrigger = false; } }
public static void FromCollider3D(VLSObstructor _obstructor, Collider _collider) { _obstructor.ClearLocalVertices(); if(_collider is BoxCollider) { From3DBoxCollider(_obstructor, _collider as BoxCollider); return; } if(_collider is SphereCollider) { FromSphereCollider(_obstructor, _collider as SphereCollider, _obstructor.circleResolution); return; } if(_collider is MeshCollider) { Debug.LogWarning("MeshCollider is not currently supported in VLS2D 4.0."); return; } if(_collider is CapsuleCollider) { Debug.LogWarning("CapsuleCollider is not currently supported in VLS2D 4.0."); return; } }
void Start() { myColor = GetComponent<Renderer>().material.color; myCollider = GetComponent<Collider>(); //myMenu = GetComponent<Transform>().parent.gameObject.GetComponent<MenuController>(); -> voir ligne 43 / 44 transform.TransformPoint(1, 0, 0); }
public void OnTriggerEnter(UnityEngine.Collider other) { if (other.gameObject.tag == "Enemy") { mainCamera.GetComponent <GameManagement>().isFailed = 1; } }
private void OnTriggerExit(UnityEngine.Collider other) { if (other.gameObject.CompareTag("nodecolliders")) { other.gameObject.GetComponent <AudioSource>().Play(); } }
/// <summary> /// Creates a unity collider that represents the body shape /// </summary> public override void CreateUnityColliders() { if (!CanCreateUnityColliders()) { return; } #if UNITY_EDITOR if (UnityEditor.EditorApplication.isPlaying) { #endif // Get rid of any existing colliders DestroyUnityColliders(); // Recreate the collider Transform lTransform = (_Transform != null ? _Transform : _Parent); float lScale = ((lTransform.lossyScale.x + lTransform.lossyScale.y + lTransform.lossyScale.z) / 3f); SphereCollider lCollider = lTransform.gameObject.AddComponent <SphereCollider>(); lCollider.radius = _Radius / lScale; lCollider.center = _Offset / lScale; if (mColliders == null || mColliders.Length == 0) { mColliders = new UnityEngine.Collider[1]; } mColliders[0] = lCollider; #if UNITY_EDITOR } #endif }
public void CameraFollowImmediately(int id) { UnityEngine.GameObject obj = LogicSystem.GetGameObject(id); if (null != obj) { m_CurTargetId = id; m_Target = obj.transform; UnityEngine.Collider collider = m_Target.GetComponent <UnityEngine.Collider>(); if (null != collider) { m_CurTargetPos = m_Target.position; m_CenterOffset = collider.bounds.center - m_Target.position; m_HeadOffset = m_CenterOffset; m_HeadOffset.y = collider.bounds.max.y - m_Target.position.y; m_IsFollow = true; Cut(); } else { m_IsFollow = false; } m_IsFollowEnable = true; m_IsShaking = false; } }
void OnTriggerEnter(UnityEngine.Collider other) { if (!other.gameObject.CompareTag("Player")) { Destroy(gameObject); } }
private void OnTriggerEnter(UnityEngine.Collider other) { if (other.tag == "Ball") { print("Ura"); } }
private void OnTriggerEnter(UnityEngine.Collider other) { if (other.gameObject.tag == "W1") { Debug.Log("몬스터피격"); Enemy.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); Enemy.GetComponent <Rigidbody>().AddForce(7, 5f, 0, ForceMode.VelocityChange); Enemy.GetComponent <MeshRenderer>().material.color = Color.red; } if (other.gameObject.tag == "P1") { Debug.Log("몬스터가플레이어공격"); Enemy.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); Enemy.GetComponent <Rigidbody>().AddForce(7, 5f, 0, ForceMode.VelocityChange); } if (other.gameObject.tag == "Ground") { Debug.Log("착지완료"); Enemy.GetComponent <MeshRenderer>().material.color = Color.white; } if (other.gameObject.tag == "Bullet") { Debug.Log("몬스터가화살에맞음"); Enemy.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); Enemy.GetComponent <Rigidbody>().AddForce(7, 5f, 0, ForceMode.VelocityChange); Enemy.GetComponent <MeshRenderer>().material.color = Color.red; Destroy(other.gameObject); } }
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 ); }
private void OnTriggerEnter(UnityEngine.Collider other) { if (other.CompareTag("Obstacle")) { isOnGround = true; } }
// 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; } }
// Destroy blob on leaving arena void OnTriggerEnter(UnityEngine.Collider other) { Blob collideBlob = other.gameObject.GetComponent <Blob>(); if (collideBlob != null) { //Reverses direction of blob if running into a wall with enough Safe Bounces remaining if (collideBlob.SafeBouncesRemaining > 0) { if (collideBlob.MovingState != null) { collideBlob.SafeBouncesRemaining--; collideBlob.MovingState.ReverseDirection(); print("Boing"); } else { print("Not in moving state"); } } else { collideBlob.Kill(); } } }
void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) return; if (Time.time < timer) { if (!targetsAlreadyTouched.Contains(other.gameObject.GetInstanceID())) { IDamageable damageable = other.GetComponent(typeof(IDamageable)) as IDamageable; if (damageable == null) { return; } targetsAlreadyTouched.Add(other.gameObject.GetInstanceID()); damageable.TakeDirectDamage(DoDamage()); //Target spreading. if (damageable is AlienBase) { AlienBase alien = damageable as AlienBase; alien.SetTarget(damageSource.transform); } if (damageable is CocoonSpawner) (damageable as CocoonSpawner).TriggerSpawning(damageSource.transform); } } }
/** * on trigger enter is triggered when a collision occurs * handles main behavior of a hit with the enzyme guy's mouth */ void OnTriggerEnter(UnityEngine.Collider other) { // check if the object in the collision has a parent if (other.gameObject.transform.parent && other.gameObject.transform.parent.gameObject.name.Contains("Particle Parent")) { MeshRenderer particleRenderer = other.gameObject.transform.parent.gameObject.GetComponentsInChildren <MeshRenderer> () [0]; // check if the enzyme guy and the particle(s) are the same color if (transform.parent.GetComponent <Renderer>().material.color == particleRenderer.material.color) { //split food particle ParticleSplit split = other.gameObject.transform.parent.gameObject.GetComponent <ParticleSplit> (); split.Split(); // destroy old one Destroy(other.gameObject.transform.parent.gameObject); } else { // if they weren't the same color then destroy (kill) the enzyme guy Destroy(transform.parent.gameObject); } } }
void OnTriggerEnter(Collider other) { if (other.name == "Player") GameManager.instance.GameOver(); else if (!other.tag.Contains(ignoredTag)) Destroy(other.gameObject); }
private void OnTriggerExit(UnityEngine.Collider other) { if (GameController.locks.Contains(gameObject)) { stayTime = 0; } }
//void Update() // { //added by Dan // messageData data = new messageData(); //data.itemToBeHeld = other.transform.root.gameObject; // this.gameObject.SendMessageUpwards("isGrabButtonPressed", data); // if (data.isButtonPressed) // { // GetComponent<Collider>().enabled = true; // GetComponent<Collider>().enabled = false; //if (other.gameObject.GetComponent<Object>() == true) //{ // other.GetComponent<Rigidbody>().isKinematic = true; //} // } //added by Dan // } void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "grab") { heldObj = this.gameObject; } }
static public int constructor(IntPtr l) { UnityEngine.Collider o; o = new UnityEngine.Collider(); pushObject(l, o); return(1); }
public override void OnTriggerEnter(Collider collider) { if(collider.gameObject.GetComponent<UnitPlayer>()!=null){ GameControl.GameOver(true); Triggered(); } }
internal override void Patch(UnityCollider collider) { if (collider is MeshCollider meshCollider) { Patch(meshCollider); } }
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 }); } }
internal void Initialize(UnityCollider unityCollider, ColliderType?shape = null) { _ownerActor = unityCollider.gameObject.GetComponent <Actor>() ?? throw new Exception("An MRE collider must be associated with a Unity game object that is an MRE actor."); _collider = unityCollider; if (shape.HasValue) { Shape = shape.Value; } else if (unityCollider is SphereCollider) { Shape = ColliderType.Sphere; } else if (unityCollider is BoxCollider) { Shape = ColliderType.Box; } else if (unityCollider is CapsuleCollider) { Shape = ColliderType.Capsule; } else if (unityCollider is MeshCollider) { Shape = ColliderType.Mesh; } }
void OnTriggerEnter(Collider col) { if (col.tag == "Fire") { hasFireContact = true; } }
//OnTriggerEnter or OnCollisionEnter? private void OnTriggerEnter(UnityEngine.Collider other) { if (other.gameObject.tag == "Tile") { GameTile t = other.gameObject.GetComponent <GameTile>(); if (t && this.target_tile.Equals(t)) { this.current_tile = t; StayOnTile(); if (this.moves_remaining > 0 || t.GetType().ToString() == "ForkTile") { this.current_tile.OnTransit(this); } else { this.current_tile.OnFinalLand(this); if (current_tile is TeleportationTile) { Invoke("EndTurn", 2.0f); } else { EndTurn(); } } } } }
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!"); } }
public void OnTriggerEnter(UnityEngine.Collider a) { if (fn != null) { fn.invoke(gameObject, a); } }
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; }
public static float ComputeVolume(UnityEngine.Collider coll) { if (coll != null) { UnityEngine.CapsuleCollider collider = coll as UnityEngine.CapsuleCollider; if (collider != null) { UnityEngine.Vector3 lossyScale = collider.transform.lossyScale; float num = collider.height * lossyScale.y; float num2 = collider.radius * UnityEngine.Mathf.Max(lossyScale.x, lossyScale.z); float num3 = (3.141593f * num2) * num2; float num4 = num3 * num; float num5 = (num3 * num2) * 1.333333f; return(num4 + num5); } UnityEngine.SphereCollider collider2 = coll as UnityEngine.SphereCollider; if (collider2 != null) { UnityEngine.Vector3 vector2 = collider2.transform.lossyScale; float[] values = new float[] { vector2.x, vector2.y, vector2.z }; float num6 = collider2.radius * UnityEngine.Mathf.Max(values); return(4.18879f * ((num6 * num6) * num6)); } UnityEngine.BoxCollider collider3 = coll as UnityEngine.BoxCollider; if (collider3 != null) { UnityEngine.Vector3 vector3 = collider3.transform.lossyScale; UnityEngine.Vector3 size = collider3.size; return(((size.x * vector3.x) * (size.y * vector3.y)) * (size.z * vector3.z)); } UnityEngine.Debug.LogWarning("Not implemented for " + coll.GetType() + " type!"); } return(0f); }
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); } }
/// <summary> /// Regroup all tutorial event. /// These events are add to the player event which already exist. /// </summary> /// <param name="colInfo"> Gameobject which the player enter in collision. </param> private void OnTriggerEnter(UnityEngine.Collider other) { /// Case where the movement tutorial is ending. if (other.gameObject.CompareTag("MOVEMENT")) { obstacleWall.SetTrigger("Enter"); obstaclePanel.SetActive(true); } /// Case where the obstacle tutorial is ending. if (other.gameObject.CompareTag("OBSTACLE")) { jumpWall.SetTrigger("Enter"); jumpPanel.SetActive(true); } /// Case where the jump tutorial is ending. if (other.gameObject.CompareTag("JUMP")) { goalWall.SetTrigger("Enter"); goalPanel.SetActive(true); } /// Case where the tutorial is ending. if (other.gameObject.CompareTag("END")) { endPanel.SetActive(true); } }
private void OnTriggerEnter(Collider other) { // Collect all the colliders in a sphere from the shell's current position to a radius of the explosion radius. Collider[] colliders = Physics.OverlapSphere(transform.position, m_ExplosionRadius, CharactersMask); for (int i = 0; i < colliders.Length; i++) { Rigidbody targetRigidbody = colliders[i].GetComponent<Rigidbody>(); if (!targetRigidbody) continue; CharacterHealth targetHealth = targetRigidbody.GetComponent<CharacterHealth>(); if (targetHealth) { Vector3 explosionToTarget = targetRigidbody.position - transform.position; float explosionDistance = explosionToTarget.magnitude; float relativeDistance = (m_ExplosionRadius - explosionDistance) / m_ExplosionRadius; float damage = relativeDistance * m_MaxDamage; damage = Mathf.Max (0f, damage); targetHealth.Damage (damage); } } //if we are ALSO client (so hosting), this will be done by the Destroy so Skip if (!NetworkClient.active) PhysicForces(); // Destroy the shell on clients. NetworkServer.Destroy(gameObject); }
internal override void Patch(UnityCollider collider) { if (collider is SphereCollider sphereCollider) { Patch(sphereCollider); } }
private void Start() { if (Application.isPlaying == true) { if (CameraSystem.Instance == null) { Debug.LogErrorFormat(this, "{0} could not find an instance of CameraSystem!", this); this.enabled = false; return; } switch (this._triggerColliderType) { case TriggerColliderType.Box: this._collider = this.gameObject.AddOrGetComponent<BoxCollider>(); break; case TriggerColliderType.Sphere: this._collider = this.gameObject.AddOrGetComponent<SphereCollider>(); break; case TriggerColliderType.ConvexMesh: this._collider = this.gameObject.AddOrGetComponent<MeshCollider>(); (this._collider as MeshCollider).sharedMesh = this._mesh; (this._collider as MeshCollider).convex = true; break; } this._collider.isTrigger = true; this._collider.hideFlags = HideFlags.HideInInspector; this._triggerGates = new List<ITriggerGate>(this.gameObject.GetInterfacesInChildren<ITriggerGate>(true, true)); } }
internal override void Patch(UnityCollider collider) { if (collider is BoxCollider boxCollider) { Patch(boxCollider); } }
public override void DoTriggerExit(Collider other) { if (other.gameObject.tag == collideTag.Value) { collideCount.Value = collideCount.Value - 1; } }
static void Collider_bounds(JSVCall vc) { UnityEngine.Collider _this = (UnityEngine.Collider)vc.csObj; var result = _this.bounds; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); }
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; } }
static void Collider_attachedRigidbody(JSVCall vc) { UnityEngine.Collider _this = (UnityEngine.Collider)vc.csObj; var result = _this.attachedRigidbody; JSMgr.datax.setObject((int)JSApi.SetType.Rval, result); }
public void OnTriggerEnter(Collider other) { explosionEmitter.Emit(200); volumeController.Stop(); mGameOver = true; Invoke ("StartOver", 1); }
void OnTriggerStay(Collider other) { Vector3 impulse; if (getPlayerTopYPoint() > getWaterTopYPoint()) { impulse = playerController.getCurrentMovement().getImpulse(); setInwater(); playerController.getCurrentMovement().addImpulse(impulse); if (getPlayerBodyTopY()+1f > getWaterTopYPoint()) { playerController.transform.position = new Vector3(playerController.transform.position.x, this.transform.position.y, playerController.transform.position.z); } } else { impulse = playerController.getCurrentMovement().getImpulse(); setUnderwater(); playerController.getCurrentMovement().addImpulse(impulse); } }
void OnTriggerEnter(Collider coll) { if (coll.gameObject.tag == "Player") { inTrigger = true; } }
public void OnTriggerExit(Collider other) { if (list.Contains(other.gameObject)) { list.Remove(other.gameObject); } }
/** * called when nutrient enters a collision * Checks if the blob hit the end of the path and calls clean up function if so */ void OnTriggerEnter(UnityEngine.Collider obj) { if (obj.gameObject.tag == "Finish") // check if the food blob collided with the end point, if it did handle it { OnEndPointCollision(); } }
internal override void Patch(MixedRealityExtensionApp app, UnityCollider collider) { if (collider is MeshCollider meshCollider) { Patch(app, meshCollider); } }
void OnTriggerEnter (Collider other) { if (other.gameObject == player) { shouldDamage = true; } }
internal override void Patch(MixedRealityExtensionApp app, UnityCollider collider) { if (collider is SphereCollider sphereCollider) { Patch(sphereCollider); } }
void OnTriggerEnter(Collider other) { if (other.transform.parent && other.transform.parent.CompareTag("MainPlayer")) { CameraFade.StartAlphaFade(underwater,false,0.25f,0.125f, ()=>{StartCoroutine(Keep(underwater));}); var temp = other.gameObject.GetComponentInChildren<mvmt::ThirdPersonController>(); if (temp) { temp.dead = true; var rbTemp = temp.GetComponentsInChildren<Rigidbody>(); if (rbTemp!=null) { foreach (var elem in rbTemp) { //initDrag = elem.drag; elem.drag = drag; //elem.angularDrag = drag; } } } } else {//if (other.gameObject.CompareTag("Player")) { var rbs = other.gameObject.GetComponentsInChildren<Rigidbody>(); if (rbs!=null) { foreach (var elem in rbs) { //initDrag = elem.drag; elem.drag = drag; //elem.angularDrag = drag; } } } }
internal override void Patch(MixedRealityExtensionApp app, UnityCollider collider) { if (collider is BoxCollider boxCollider) { Patch(boxCollider); } }
void OnTriggerEnter(Collider collider) { if (enter) { SerenityAgent agent = collider.GetComponent<SerenityAgent>(); Play("OnTriggerEnter",agent.agentName); } }
protected HeadsetCollisionEventArgs SetHeadsetCollisionEvent(Collider collider, Transform currentTransform) { HeadsetCollisionEventArgs e; e.collider = collider; e.currentTransform = currentTransform; return e; }
private void OnTriggerExit(UnityCollider other) { if (_colliderEventSubscriptions.HasFlag(ColliderEventType.TriggerExit)) { SendTriggerEvent(ColliderEventType.TriggerExit, other); } }
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); } }
public override void OnTriggerExit(Collider other) { if (string.IsNullOrEmpty(tag.Value) || tag.Value.Equals(other.gameObject.tag)) { otherGameObject.Value = other.gameObject; exitedTrigger = true; } }
private void OnTriggerStay(UnityEngine.Collider other) { bool higherPriority = false; //check if there is a rotator with a higher priority foreach (var r in GameController.rotatingColliders) { higherPriority = r.GetComponent <RotatorCollider>().priority > priority; } //rotate bub's parent around transform.up if (other.gameObject.CompareTag("bub") && !GameController.rotating && !GameController.moving && rotate && !GameController.rotatingSpoke && !higherPriority) { rotate = false; if (other.gameObject.transform.parent.GetComponent <RotateSpoke>() != null) { GameController.lastRotateSpoke = other.gameObject.transform.parent.GetComponent <RotateSpoke>(); GameController.lastRotateSpoke.reversing = false; other.gameObject.transform.parent.GetComponent <RotateSpoke>() .StartCoroutine(nameof(RotateSpoke.RotateIt), gameObject); if (!rotating) { StartCoroutine(Rotate()); } } else { GameController.rotatingColliders.Remove(gameObject); } } }