Hey Guys!
I’m almost finish with my first 2D-Platformer.
The last thing I want to do is to bend down my character that I don’t collide with birds. I implemented the Graphics and can call it by pressing the down button on my keyboard. The problem is: The bird applies damage on me even if I’m bend down because I have a mesh collider on my player which touches the box collider of the bird.
I thought I could fix this if I make an if-request: if my player is bend down->Turn off my mesh collider and activate a new box collider, which is smaller, that other animals on the ground can also apply damage to me.
The problem is I have really no idea how to do this.
The control for my character is in the script “PlayerController” and the apply damage function is in may “WaypointWalker” script.
It looks like this:
protected virtual void ApplyDamage (int damage)
{
if(!isHit)
{
isHit = true;
currentHealth -= damage;
AudioSource.PlayClipAtPoint(hitSound,transform.position,1);
if(currentHealth <= 0)
{
currentHealth = 0;
Die();
}
else
{
StartCoroutine (DamageEffect ());
}
}
Does anyone of you know how I can solve this problem? You would make me very happy!!!
Sarah