public void CollisionObstacle(GameObject obstacle) { if (star_active) { obstacle.GetComponent <ObstacleScript>().Leave(); score.AddScore(ScoreType.DESTROY_OBSTACLE); } else { if (evo_controller.CheckCollisionObstacle(obstacle.tag)) { obstacle.GetComponent <ObstacleScript>().Leave(); GetComponent <Rigidbody>().velocity = Vector3.zero; GetComponent <Rigidbody>().AddForce(-direction.normalized * velocity * Time.deltaTime, ForceMode.Impulse); next_position = initial_position; score.AddScore(ScoreType.DESTROY_OBSTACLE); isReturn = true; } else if (armor_active) { // Return //state = StatePlayer.RETURN; //particle_hit.transform.position = collision.contacts[0].point; //particle_hit.GetComponent<ParticleSystem>().Play(); GetComponent <Rigidbody>().velocity = Vector3.zero; GetComponent <Rigidbody>().AddForce(-direction.normalized * velocity * Time.deltaTime, ForceMode.Impulse); next_position = initial_position; isReturn = true; } else { // Die? source.PlayOneShot(defeat); GetComponent <Rigidbody>().velocity = Vector3.zero; GetComponent <TrailRenderer>().enabled = false; transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z - 5); //Set animation to Idle GetComponent <Animator>().SetBool("Hit", true); GetComponent <Rigidbody>().useGravity = true; state = StatePlayer.DYING; } } }