UnityEngine.Physics.IgnoreCollision(UnityEngine.Collider, UnityEngine.Collider)

Here are the examples of the csharp api UnityEngine.Physics.IgnoreCollision(UnityEngine.Collider, UnityEngine.Collider) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

19 View Source File : RearBumperBehaviour.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

void Start()
        {
            coll = GetComponent<Collider>();
            ignored = new List<Collider>();
            fsm = gameObject.GetPlayMakerFSM("BoltCheck");

            seekColliders = transform.root == Satsuma.Instance.transform;
            if (seekColliders)
            {
                Collider[] colls = Physics.OverlapSphere(transform.position, 5);
                foreach (Collider coll in colls)
                {
                    if (coll.transform.root == Satsuma.Instance.transform)
                    {
                        Physics.IgnoreCollision(this.coll, coll);
                        ignored.Add(coll);
                    }
                }

                StartCoroutine(ReloadBolts());
            }
        }

19 View Source File : RearBumperBehaviour.cs
License : GNU General Public License v3.0
Project Creator : Athlon007

void OnCollisionEnter(Collision other)
        {
            if (!seekColliders) return;

            if (other.transform.root == Satsuma.Instance.transform && !ignored.Contains(other.collider))
            {
                Physics.IgnoreCollision(coll, other.collider);
                ignored.Add(other.collider);
            }
        }

19 View Source File : Arrow.cs
License : MIT License
Project Creator : dag10

void Start()
		{
			Physics.IgnoreCollision( shaftRB.GetComponent<Collider>(), Player.instance.headCollider );
		}

19 View Source File : Arrow.cs
License : MIT License
Project Creator : dag10

void OnCollisionEnter( Collision collision )
		{
			if ( inFlight )
			{
				Rigidbody rb = GetComponent<Rigidbody>();
				float rbSpeed = rb.velocity.sqrMagnitude;
				bool canStick = ( targetPhysMaterial != null && collision.collider.sharedMaterial == targetPhysMaterial && rbSpeed > 0.2f );
				bool hitBalloon = collision.collider.gameObject.GetComponent<Balloon>() != null;

				if ( travelledFrames < 2 && !canStick )
				{
					// Reset transform but halve your velocity
					transform.position = prevPosition - prevVelocity * Time.deltaTime;
					transform.rotation = prevRotation;

					Vector3 reflfectDir = Vector3.Reflect( arrowHeadRB.velocity, collision.contacts[0].normal );
					arrowHeadRB.velocity = reflfectDir * 0.25f;
					shaftRB.velocity = reflfectDir * 0.25f;

					travelledFrames = 0;
					return;
				}

				if ( glintParticle != null )
				{
					glintParticle.Stop( true );
				}

				// Only play hit sounds if we're moving quickly
				if ( rbSpeed > 0.1f )
				{
					hitGroundSound.Play();
				}

				FireSource arrowFire = gameObject.GetComponentInChildren<FireSource>();
				FireSource fireSourceOnTarget = collision.collider.GetComponentInParent<FireSource>();

				if ( arrowFire != null && arrowFire.isBurning && ( fireSourceOnTarget != null ) )
				{
					if ( !hreplacedpreadFire )
					{
						collision.collider.gameObject.SendMessageUpwards( "FireExposure", gameObject, SendMessageOptions.DontRequireReceiver );
						hreplacedpreadFire = true;
					}
				}
				else
				{
					// Only count collisions with good speed so that arrows on the ground can't deal damage
					// always pop balloons
					if ( rbSpeed > 0.1f || hitBalloon )
					{
						collision.collider.gameObject.SendMessageUpwards( "ApplyDamage", SendMessageOptions.DontRequireReceiver );
						gameObject.SendMessage( "HasAppliedDamage", SendMessageOptions.DontRequireReceiver );
					}
				}

				if ( hitBalloon )
				{
					// Revert my physics properties cause I don't want balloons to influence my travel
					transform.position = prevPosition;
					transform.rotation = prevRotation;
					arrowHeadRB.velocity = prevVelocity;
					Physics.IgnoreCollision( arrowHeadRB.GetComponent<Collider>(), collision.collider );
					Physics.IgnoreCollision( shaftRB.GetComponent<Collider>(), collision.collider );
				}

				if ( canStick )
				{
					StickInTarget( collision, travelledFrames < 2 );
				}

				// Player Collision Check (self hit)
				if ( Player.instance && collision.collider == Player.instance.headCollider )
				{
					Player.instance.PlayerShotSelf();
				}
			}
		}

19 View Source File : IgnoreInternalCollisions.cs
License : Apache License 2.0
Project Creator : OOXXXXOO

void Start () {
    Collider[] colliders = gameObject.GetComponentsInChildren<Collider>();
    for (int i = 0; i < colliders.Length; ++i)
      for (int j = i + 1; j < colliders.Length; ++j)
        Physics.IgnoreCollision(colliders[i], colliders[j]);
	}

19 View Source File : MainController.cs
License : Apache License 2.0
Project Creator : wuhan005

void NewAttack(GameObject From, GameObject To, int flashIndex = 0)
    {
        Vector3[] paths = new Vector3[3];

        int speed = 500;

        // 炮弹实例
        GameObject projectile;
        projectile = Instantiate(this.flash[flashIndex], From.GetComponent<Transform>().position, Quaternion.idenreplacedy) as GameObject;

        // 忽略炮弹与炮弹之间的碰撞
        Physics.IgnoreLayerCollision(9, 9);

        // 忽略发射者与炮弹的碰撞
        Physics.IgnoreCollision(From.GetComponent<Collider>(), projectile.GetComponent<Collider>());

        paths[0] = From.GetComponent<Transform>().position;
        paths[2] = To.GetComponent<Transform>().position;
        paths[1] = new Vector3((paths[2].x + paths[0].x) / 2, 5, (paths[2].z + paths[0].z) / 2);

        projectile.GetComponent<Rigidbody>().AddForce(projectile.transform.forward * speed);

        iTween.MoveTo(projectile, iTween.Hash("path", paths, "movetopath", true, "orienttopath", true, "time", 1, "easetype", iTween.EaseType.linear));

        // 设置状态为被攻陷
        To.GetComponent<SinglePlanet>().SetAttack(true);
    }