private void OnCollisionEnter2D(Collision2D collision) { string collisionTag = collision.gameObject.tag; if (collisionTag != "Block" && collisionTag != "Ground" && collisionTag != "Player") //Enemy turns around when hitting collidable object that is not player or ground { moveSpeed *= -1; } else if (collisionTag == "Player" && !headHit) //If player hits enemy but not from above, kill player { //Player dies if (trackerPU.isStar) { KillEnemy(); } else { playerDeath = FindObjectOfType <PlayerDeath>(); playerDeath.DeathChecker(); } } }
private void FixedUpdate() { vecTLBoundary = topLeftBoundary.transform.position; botBoundary = bottomBoundary.transform.position.y; //Faster fall time if (rBody.velocity.y < -0.01) { rBody.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime; } if (isGrounded) { animator.SetBool("Jump", false); if (horiz != 0) { animator.SetFloat("Horizontal", horiz); animator.SetBool("Walking", true); } else if (horiz == 0) { animator.SetBool("Walking", false); } } else { animator.SetBool("Jump", true); } //If player has fallen if (transform.position.y < bottomBoundary.transform.position.y & !death) { death = true; trackerPU.isBig = false; playerDeath.DeathChecker(); } }