//****************************************************************** OnTriggerEnter2D function ****************************************************************** //This function defines behavior once another entity with a collider enters an IsTrigger collision with this entity's colliders //Our radius for the enemy is an IsTrigger collision, meaning it will begin targeting the player when the radius is touched private void OnTriggerEnter2D(Collider2D collision) { //Collision must be with the player's collider if (collision.gameObject.tag == "Player") { playerFound = true; //if (Vector3.Distance(collision.gameObject.transform.position, this.transform.position) > 0) //{ // ene //} } if (collision.gameObject.tag == "PlayerHit") { Debug.Log("Hit"); //hit testing StartCoroutine(FlashColor()); V3PlayerCharacterControler temp = collision.gameObject.GetComponentInParent <V3PlayerCharacterControler>(); float tempDamage = temp.meleeDamageValue; ApplyDamage(tempDamage); } if (collision.gameObject.tag == "BulletHit") { Debug.Log("Hit"); //hit testing StartCoroutine(FlashColor()); float receivedDamage = collision.gameObject.GetComponent <Bullet>().damage; ApplyDamage(receivedDamage); } }
void Awake() { _player = FindObjectOfType <V3PlayerCharacterControler>(); _playerRigidBody = _player.GetComponent <Rigidbody2D>(); _initialPlayerGravity = _playerRigidBody.gravityScale; _teleportDelay = 0.5f; _canTeleport = true; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "PlayerHit") { _takeDamageAudio.Play(); V3PlayerCharacterControler temp = collision.gameObject.GetComponentInParent <V3PlayerCharacterControler>(); float tempDamage = temp.meleeDamageValue; TakeDamage(tempDamage); } if (collision.gameObject.tag == "Player") { V3PlayerCharacterControler playerChar = collision.GetComponent <V3PlayerCharacterControler>(); playerChar.ApplyDamage(5); } }
void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { V3PlayerCharacterControler playerChar = collision.GetComponent <V3PlayerCharacterControler>(); playerChar.ApplyDamage(damage); Destroy(gameObject); } if (collision.gameObject.tag == "Environment") { Destroy(gameObject); } if (Spread != null) { Spread.GetComponent <ParticleSystem>().Play(); } }
public void Animate(bool isGrounded, float horizontalMove) { if (canLoop) { if (isGrounded) { if (activeAnimationState != CharacterAnimationState.idle && horizontalMove == 0) { PlayIdleAnimation(); if (gameObject.tag == "Player") { V3PlayerCharacterControler player = FindObjectOfType <V3PlayerCharacterControler>(); //TODO - MWB - Make less expensive. This is BAD player.soundManager.StopRunSound(); player.weapon.Show(); } } else if (activeAnimationState != CharacterAnimationState.run && horizontalMove != 0) { PlayRunAnimation(); if (gameObject.tag == "Player") { V3PlayerCharacterControler player = FindObjectOfType <V3PlayerCharacterControler>();//TODO - MWB - Make less expensive. This is BAD player.soundManager.PlayRunSound(); player.weapon.Hide(); } } } else { if (activeAnimationState != CharacterAnimationState.jump) { if (gameObject.tag == "Player") { V3PlayerCharacterControler player = FindObjectOfType <V3PlayerCharacterControler>(); //TODO - MWB - Make less expensive. This is BAD player.soundManager.StopRunSound(); player.weapon.Show(); } PlayJumpAnimation(); } } } }