示例#1
0
 private void OnCollisionExit(Collision col)
 {
     if (col.gameObject.tag == "Player")
     {
         col.gameObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
     }
 }
示例#2
0
        private IEnumerator OnCollisionEnter(Collision col)
        {
            if (enabled)
            {
                if (col.contacts.Length > 0) 
                {
                    // compare relative velocity to collision normal - so we don't explode from a fast but gentle glancing collision
                    float velocityAlongCollisionNormal =
                        Vector3.Project(col.relativeVelocity, col.contacts[0].normal).magnitude;

                    if (velocityAlongCollisionNormal > detonationImpactVelocity || exploded)
                    {

                        if (!exploded)
                        {
                            Instantiate(explosionPrefab, col.contacts[0].point,
                                        Quaternion.LookRotation(col.contacts[0].normal));
                            exploded = true;

                            SendMessage("Immobilize");

                            if (reset)
                            {
                                GetComponent<ObjectResetter>().DelayedReset(resetTimeDelay);
                            }
                        }
                    }
                }
            }

            yield return null;
        }
示例#3
0
		// Re-enable fixed time step smoothing on the characters that exited this platform
		void OnCollisionExit(Collision collision) {
			if (collision.gameObject.layer == characterLayer) {
				CharacterThirdPerson c = collision.gameObject.GetComponent<CharacterThirdPerson>();
				if (c == null) return;
				c.smoothPhysics = true;
			}
		}
 void OnCollisionStay(Collision aCollision)
 {
     if(m_Character != null)
     {
     m_Character.OnCollisionStay(aCollision);
     }
 }
				void OnCollisionEnter (Collision collision)
				{
						if (TargetValidator != null && !TargetValidator.Test (collision.gameObject))
								return;

						BoolValue = true;
				}
 void OnCollisionEnter(Collision collision) {
   Rigidbody r = collision.collider.attachedRigidbody;
   // hit floor
   if (r == null) {
     StartDisableTimer();
     return;
   }
   bool topBottom = false;
   Vector3 projectedUp = Vector3.Project(transform.up, Vector3.up);
   topBottom = projectedUp.y < 0;
   // hit pan
   if (((1 << collision.collider.gameObject.layer) & PanMask.value) > 0) {
     IsOnPan = true;
     CookSide(topBottom);
   }
   // hit plate
   else if (((1 << collision.collider.gameObject.layer) & PlateMask.value) > 0) {
     IsOnPlate = true;
     Dispenser.PanConstraints.LockedObjects.Remove(transform);
   }
   // hit pancake
   else if (((1 << collision.collider.gameObject.layer) & PancakeMask.value) > 0) {
     PancakeCookedDetector otherPancake = r.GetComponent<PancakeCookedDetector>();
     if (otherPancake.IsOnPan) {
       CookSide(topBottom);
     }
   }
 }
示例#7
0
 private void OnCollisionEnter(Collision collision)
 {
     if (inFlight)
     {
         ResetArrow();
     }
 }
示例#8
0
 private void OnCollisionStay(Collision coll)
 {
     if (player.Onesie.type == OnesieType.Hamster)
         rb.isKinematic = false;
     else
         rb.isKinematic = true;
 }
示例#9
0
 void OnCollisionStay(Collision collision)
 {
     if (collision.gameObject && collision.gameObject.tag == "Hero")
     {
         eventCollistionStayHero(this, collision.gameObject.GetComponent<Hero>());
     }
 }
        /// <summary>
        /// Raises the collision enter event.
        /// </summary>
        /// <param name="other">Other.</param>
        void OnCollisionEnter(Collision other)
        {
            if (other.gameObject.tag == "Obstacle")
            {
                //explode vehicle
                GameObject fragments = (GameObject)Instantiate(this.VehicleFragments, this.Vehicle.transform.position,this.Vehicle.transform.rotation);
                fragments.GetComponent<VehicleExplosion>().Explode(vehicleController.MoveDirection);

                Destroy(this.Vehicle);

                //deactivate thrusters
                vehicleController.LeftThruster.gameObject.SetActive(false);
                vehicleController.RightThruster.gameObject.SetActive(false);
                vehicleSound.PassBySound.Stop();
                Music.Stop();
                this.audio.Play();
                //vehicleExplosion.Play();

                Gameplay.World.WorldSpawnManager.Instance.GameRunning = false;

                guiReplay.StartMenuReplay();

                //Vector3 posRacer = gameObject.transform.position+new Vector3(0,0,-13.5f);

                //Object exp = Instantiate(explosion, posRacer, Quaternion.identity);
                //Object flames = Instantiate(fire, posRacer, Quaternion.identity);

                Debug.Log ("Collision bla with " + other.gameObject.name);
            }
        }
 void OnCollisionEnter(Collision other)
 {
     if (target_ == null && IsHand(other))
       {
     target_ = other.gameObject;
       }
 }
示例#12
0
 void OnCollisionEnter(Collision coll)
 {
     if(coll.collider.tag == "Player" && !Pressed && !done)
     {
         Press();
     }
 }
 public override void DoCollisionEnter(Collision collisionInfo)
 {
     if (runFsm.HandleCollisionEnter)
     {
         runFsm.OnCollisionEnter(collisionInfo);
     }
 }
示例#14
0
 public override void OnCollisionExit(Collision collision)
 {
     if (string.IsNullOrEmpty(tag.Value) || tag.Value.Equals(collision.gameObject.tag)) {
         collidedGameObject.Value = collision.gameObject;
         exitedCollision = true;
     }
 }
示例#15
0
        void OnCollisionEnter(Collision collision)
        {
            pon = collision.gameObject.GetComponent<IAPon>();

            if(pon != null)
                pon.Damage(damage);
        }
示例#16
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag.Equals(tagType)) {
         Destroy(col.gameObject);
         Destroy(gameObject);
     }
 }
 public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
 {
     this.hitNode = hitNode;
     collider = colliderObj;
     collision = collisionObj;
     controllerColliderHit = cchit;
 }
示例#18
0
 void OnCollisionEnter(Collision col)
 {
     var weHit = col.gameObject;
     if(weHit.tag.Equals("Pickupable")) {
         weHit.transform.position = new Vector3(weHit.transform.position.x, 100, weHit.transform.position.z);
     }
 }
        private void OnCollisionEnter(Collision col)
        {
            AsyncFractureResult[] results = new AsyncFractureResult[Explosives.Length];

            for (int i = 0; i < Explosives.Length; i++)
            {
                if (Explosives[i] != null && Explosives[i].gameObject.activeSelf)
                {
                    results[i] = Explosives[i].Fracture();
                }
            }

            for (int i = 0; i < results.Length; i++)
            {
                if (results[i] != null)
                {
                    while (!results[i].IsComplete)
                    {
            #if !UNITY_METRO || UNITY_EDITOR
                        Thread.Sleep(1);
            #endif
                    }

                    Explode(results[i].PiecesRoot, results[i].EntireMeshBounds);
                }
            }
        }
示例#20
0
 void OnCollisionEnter(Collision collision)
 {
     Utils.Log("Collision detected with {0}", collision.gameObject.name);
     Utils.Log("Collider is {0}", collision.collider);
     foreach(ContactPoint c in collision.contacts)
     {
         Utils.Log("Contact point: this collider {0}; other collider {1}", c.thisCollider, c.otherCollider);
         Utils.Log("other collider tag: {0}", c.otherCollider.tag);
         Utils.Log("Other pmat: bounce {0}, dynFric {1}, statFric {2}",
             c.otherCollider.material.bounciness,
             c.otherCollider.material.dynamicFriction,
             c.otherCollider.material.staticFriction);
         Utils.Log("Other pmat: bounce-comb {0}, Fric-comb {1}, dynFric2 {2}, statFric2 {3}, FricDir2 {4}",
             c.otherCollider.material.bounceCombine,
             c.otherCollider.material.frictionCombine,
             c.otherCollider.material.dynamicFriction2,
             c.otherCollider.material.staticFriction2,
             c.otherCollider.material.frictionDirection2);
         foreach(Wheel w in wheels)
         {
             Utils.Log("Wheel {0}", w.wheelName);
             Utils.Log("forwardFriction.stiffness {0}, sidewaysFriction.stiffness {1}",
                 w.whCollider.forwardFriction.stiffness, w.whCollider.sidewaysFriction.stiffness);
             Utils.Log("forwardFriction.asymptote {0}, sidewaysFriction.asymptote {1}",
                 w.whCollider.forwardFriction.asymptoteValue, w.whCollider.sidewaysFriction.asymptoteValue);
             Utils.Log("forwardFriction.a-slip {0}, sidewaysFriction.a-slip {1}",
                 w.whCollider.forwardFriction.asymptoteSlip, w.whCollider.sidewaysFriction.asymptoteSlip);
             Utils.Log("forwardFriction.extremum {0}, sidewaysFriction.extremum {1}",
                 w.whCollider.forwardFriction.extremumValue, w.whCollider.sidewaysFriction.extremumValue);
             Utils.Log("forwardFriction.e-slip {0}, sidewaysFriction.e-slip {1}",
                 w.whCollider.forwardFriction.extremumSlip, w.whCollider.sidewaysFriction.extremumSlip);
         }
     }
 }
示例#21
0
        public override void OnCollisionEnter(Collision col)
        {
            var newCollisionType = ballController.GetCollisionType (col);
            switch (lastCollision) {
            case BallController.COLLISION_TYPE.OWN_OBJECT:
                // skoro uderzylismy w nasza kule, nie robimy penaty
                break;
            case BallController.COLLISION_TYPE.OTHER_OBJECT:
                //
                break;
            case BallController.COLLISION_TYPE.NONE:
                // nie było jeszcze kolizji
                switch (newCollisionType) {
                case BallController.COLLISION_TYPE.OWN_OBJECT:
                    // wszystko jest ok, kolizja w naszą kulę jest wskazana
                    break;
                case BallController.COLLISION_TYPE.OTHER_OBJECT:
                    ChangeState (new PenaltyState (PenaltyState.PENALTY_TYPE.BIG, col));
                    break;
                }
                break;
            }

            lastCollision = newCollisionType;
        }
示例#22
0
 static public int get_rigidbody(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.Collision self = (UnityEngine.Collision)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.rigidbody);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 protected override void OnCollionEnter(Collision col)
 {
     var other = col.gameObject;
     IHealth health = other.GetComponentInterface<IHealth>();
     if (health != null)
         health.Health -= m_damage;
 }
示例#24
0
        void OnCollisionEnter(Collision col)
        {
            if (col.gameObject.tag == EnergyTags.EnergyNode)
            {

            }
        }
示例#25
0
 protected void OnCollisionStay(Collision other)
 {
     if (other.collider.CompareTag(this.targetTag)) {
         var health = other.collider.GetComponent<Health>();
         health.AddHealth(-this.damage);
     }
 }
 void OnCollisionExit(Collision other)
 {
     if (isValid(other.gameObject))
     {
         other.gameObject.GetComponent<Damageable>().ExitHit(m_Damage);
     }
 }
示例#27
0
 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject == destroyGoal)
     {
         Destroy(gameObject);
     }
 }
        private void OnCollisionEnter(Collision col)
        {
            if (col.contacts.Length > 0)
            {
                _impactBody = col.rigidbody;
                _impactMass = (col.rigidbody != null) ? col.rigidbody.mass : 1.0f;
                _impactVelocity = col.relativeVelocity;

                Rigidbody rb = GetComponent<Rigidbody>();
                if (rb != null)
                {
                    // Always have the impact velocity point in our moving direction
                    _impactVelocity *= Mathf.Sign(Vector3.Dot(rb.velocity, _impactVelocity));
                }

                float mag = _impactVelocity.magnitude;
                Vector3 force = 0.5f * _impactMass * _impactVelocity * mag;

                if ((ForceThreshold * ForceThreshold) <=
                    force.sqrMagnitude)
                {
                    _impactPoint = Vector3.zero;

                    for (int i = 0; i < col.contacts.Length; i++)
                    {
                        _impactPoint += col.contacts[i].point;
                    }
                    _impactPoint *= 1.0f / col.contacts.Length;

                    Vector3 localPoint = transform.worldToLocalMatrix.MultiplyPoint(_impactPoint);

                    GetComponent<FractureGeometry>().Fracture(localPoint);
                }
            }
        }
示例#29
0
        void OnCollisionEnter(Collision collision)
        {
            if(!IsColliderABallWithMatchingColour(collision))
                return;

            RecordHit(collision);
        }
示例#30
0
 public override void DoCollisionStay(Collision collisionInfo)
 {
     if (this.runFsm.HandleCollisionStay)
     {
         this.runFsm.OnCollisionStay(collisionInfo);
     }
 }
示例#31
0
 public override void DoCollisionExit(Collision collisionInfo)
 {
     if (this.runFsm.HandleCollisionExit)
     {
         this.runFsm.OnCollisionExit(collisionInfo);
     }
 }
示例#32
0
    private void OnCollisionEnter(UnityEngine.Collision collision)
    {
        GameObject go = collision.gameObject;

        if (go.CompareTag("chest"))
        {
            Destroy(this.gameObject);
        }
    }
示例#33
0
 void OnCollisionEnter(UnityEngine.Collision collisionInfo)
 {
     if (collisionInfo.collider.tag == "Obstacle")
     {
         GetComponent<Movement>().enabled = false;
         Debug.Log(collisionInfo.collider.name);
         FindObjectOfType<GameManager>().EndGame();
     }
 }
示例#34
0
 public Collision_info(
     string name, UnityEngine.Collision collision, GameObject game_object,
     float slope_angle = 0f)
 {
     this.name        = name;
     this.collision   = collision;
     this.game_object = game_object;
     this.slope_angle = slope_angle;
 }
示例#35
0
 void OnCollisionEnter(UnityEngine.Collision collision1)
 {
     if (collision1.collider.tag == "Obstacle")
     {
         aa.PlayOneShot(aUDIO, 10);
         movement.enabled = false;
         FindObjectOfType <GameManager>().EndGame();
     }
 }
示例#36
0
 void OnCollisionEnter(UnityEngine.Collision collision)
 {
     Debug.Log("Weszlo do procedury");
     if ((collision.gameObject.tag == "Object") || (collision.gameObject.tag == "Powerup"))
     {
         Debug.Log("Weszlo do ifa");
         Destroy(collision.gameObject);
     }
 }
示例#37
0
 void OnCollisionEnter(UnityEngine.Collision col)
 {
     //Check for a match with the specified name on any GameObject that collides with your GameObject
     if (col.gameObject.name == "Player2")
     {
         //Destroy();
         effect.Play();
     }
 }
示例#38
0
 // detect collision
 void OnCollisionEnter(UnityEngine.Collision collisionInfo)
 {
     // if hit an obstacle
     if (collisionInfo.gameObject.tag == "Obstacle")
     {
         // knock them off the course
         movement.knockOff();
     }
 }
示例#39
0
    //Gestion collisions

    private void OnCollisionEnter(UnityEngine.Collision collision)
    {
        if (collision.gameObject.tag == "wall")
        {
            this.inWall = true;
            //this.Ready = false;
            //this.IsDashing = false;
        }
    }
示例#40
0
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     // Debug.Log(collision.gameObject.name);
     if (collision.gameObject.name == "Player" && tocke >= 9)
     {
         //Debug.Log("COLLISION");
         Destroy(gameObject);
     }
 }
示例#41
0
 void OnCollisionEnter(UnityEngine.Collision other)
 {
     if (other.gameObject.tag == "egg")
     {
         _gameManager.collectedEggs++;
         _gameManager.cash += 0.5f;
         Destroy(other.gameObject);
     }
 }
示例#42
0
    public void OnCollisionEnter(UnityEngine.Collision Obstacle)

    {
        if (Obstacle.gameObject.name == "Player")
        {
            //bool boll = true;
            FindObjectOfType <GameManager>().EndGame();
        }
    }
示例#43
0
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.other.tag == "StandardClashObject")
     {
         GetComponent <Walking>().Stunned = true;
         StunCounter         = StunDuration;
         collision.other.tag = "InactiveObject";
     }
 }
示例#44
0
 // destorys itself if it hits a something that isn't the player
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.gameObject.tag != "Player")
     {
         if (collision.gameObject.tag != this.gameObject.tag)
         {
             Destroy(this.gameObject);
         }
     }
 }
 public void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.gameObject.tag == "P1")
     {
         rend.sharedMaterial = material;
         d            = true;
         anim.enabled = true;
         //Debug.Log("Hit!");
     }
 }
示例#46
0
 void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (GameObject.FindGameObjectWithTag("Player").GetComponent <Collider>() == collision.collider)
     {
         if (gameObject.GetComponent <Animator>() != null)
         {
             Destroy(gameObject.GetComponent <Animator>());
         }
     }
 }
示例#47
0
    private void OnCollisionEnter(UnityEngine.Collision collision)
    {
        print("OnCollisionEnter" + collision.gameObject.name);
        Object _obj = gameObject;

        if (collision.gameObject.name == "Sphere(Clone)")
        {
            Destroy(_obj);
        }
    }
示例#48
0
 public void OnCollisionEnter(UnityEngine.Collision collisionInfo)
 {
     if (collisionInfo.gameObject.tag == "Enemy")
     {
         // Two ways to do this first one is commented
         // movement.enabled = false;
         GetComponent <playerMovement>().enabled = false;
         FindObjectOfType <GameManager>().Endgame();
     }
 }
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.gameObject.layer == 11)
     {
         float distancia = Vector3.Distance(collision.gameObject.GetComponent <PlayerBehaviour>().transform.position, this.origem);
         this.CalcularDano(distancia);
         collision.gameObject.GetComponent <PlayerBehaviour>().LevaDano(this.dano);
         Destroy(this.gameObject);
     }
 }
示例#50
0
    private float[] getCollisionData(UnityEngine.Collision col)
    {
        float[] collisionData = new float[2];
        Vector3 colVec        = col.contacts[0].point;

        collisionData[0] = colVec.z;
        collisionData[1] = colVec.x;
        //Debug.Log(colVec.x);
        return(collisionData);
    }
 protected void CheckAngleOnExit(UnityEngine.Collision other)
 {
     if (PhysicsTools.IsLayerInMask(LayersToCheck, other.gameObject.layer))
     {
         if (currentCollisions.Contains(other.gameObject))
         {
             currentCollisions.Remove(other.gameObject);
         }
     }
 }
 void OnCollisionEnter(UnityEngine.Collision other)
 {
     if (other.gameObject.CompareTag("intercom"))
     {
         hit = true;
         Debug.Log("kwoongus");
         StartCoroutine(Toggle());
         //flowchart.SetBooleanVariable ("hit", true);
     }
 }
示例#53
0
 void OnCollisionExit(UnityEngine.Collision collision)
 {
     // Obje Ground tag'li objeyle teması kestiyse;
     if (collision.gameObject.CompareTag("Ground"))
     {
         // Havadayız
         onAir      = true;
         isGrounded = false;
     }
 }
示例#54
0
 void OnCollisionEnter(UE.Collision collisionInfo)
 {
     // for (var index = 0; index < collisionInfo.contactCount; index++)
     // {
     //  var contact = collisionInfo.contacts[index];
     //  Debug.DrawRay(contact.point, contact.normal * 1.5f, Color.red, 0.1f);
     //  // Debug.Log(name + " |Enter| " + "," + contact.point + ", " + contact.separation.ToString("F5"));
     // }
     // Debug.Log(name + " |Enter| " + collisionInfo.gameObject.name);
 }
示例#55
0
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (!cube)
     {
         return;
     }
     cube.GetComponent <Destruction>().Createcube.Invoke();
     StartCoroutine(ExampleCoroutine());
     collision.gameObject.GetComponent <Rigidbody>().AddForce(transform.up * 200, ForceMode.Impulse);
 }
示例#56
0
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (collision.gameObject == floor)
     {
         dust.transform.position   = new Vector3(gameObject.transform.position.x, 0.1f, gameObject.transform.position.z);
         planks.transform.position = new Vector3(gameObject.transform.position.x, 0.1f, gameObject.transform.position.z);
         scroll.transform.position = new Vector3(gameObject.transform.position.x, 0.1f, gameObject.transform.position.z);
         activate("true");
         GameObject.Find("LocalGameSystem").GetComponent <UNETSyncObjects>().add(gameObject, ToDo.destroy, "true");
     }
 }
示例#57
0
 // Yerde olup olmadığımızı kontrol etmek için Collision Enter-Exit yapısı kullanıyoruz.
 void OnCollisionEnter(UnityEngine.Collision collision)
 {
     // Eğer objemiz bir başka objeyle çarpıştığında bu objenin tag'i ground ise;
     if (collision.gameObject.CompareTag("Ground"))
     {
         // Artık havada değiliz.
         onAir = false;
         // Yerdeyiz.
         isGrounded = true;
     }
 }
示例#58
0
 private void OnCollisionEnter(UnityEngine.Collision collisionInfo)
 {
     if (collisionInfo.collider.tag == "Wall")
     {
         usingtime = false;
     }
     if (collisionInfo.collider.tag == "WinLevel")
     {
         usingtime = false;
     }
 }
 protected void CheckAngleOnEnter(UnityEngine.Collision other)
 {
     if (PhysicsTools.IsLayerInMask(LayersToCheck, other.gameObject.layer))
     {
         float angle = Vector3.Angle(Vector3.up, other.contacts[0].normal);
         if (angle <= MaxAngle && !currentCollisions.Contains(other.gameObject))
         {
             currentCollisions.Add(other.gameObject);
         }
     }
 }
示例#60
0
 private void OnCollisionEnter(UnityEngine.Collision collision)
 {
     if (!exlosionPlayed1 && izstreljen && collision.collider.tag == "Ovira")
     {
         Destroy(gameObject, secToDestroy);
         AudioManager.playExplosion();
         exlosionPlayed1 = true;
         Explode();
         Debug.Log("Torpedo Explodiru");
     }
 }