[SOLVED] I can’t get my player to die when he falls – ep 11 how to make a 2D platformer

Updated on January 29, 2019 in [A] 2D
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
7 on January 23, 2019

My script is the same as Brackeys and I can’t seem to find the problem, any help would be greatly appreciated

  • Liked by
Reply
1 on January 24, 2019

Can we see your script?

 

on January 24, 2019

I posted it below thanks!

Show more replies
  • Liked by
Reply
Cancel
0 on January 24, 2019

public class Player : MonoBehaviour
{
[System.Serializable]
public class PlayerStats
{
public int Health = 100;
}

public PlayerStats playerStats = new PlayerStats();

public int fallBoundary = -20;

void update()
{
if(transform.position.y <= fallBoundary)
{
DamagePlayer(9999999);
}
}

public void DamagePlayer(int damage)
{
playerStats.Health -= damage;
if (playerStats.Health <= 0)
{
GameMaster.KillPlayer(this);
}
}
}

  • Liked by
Reply
Cancel
0 on January 24, 2019

public class GameMaster : MonoBehaviour
{

public static void KillPlayer(Player player)
{
Destroy(player.gameObject);
}

}

  • Liked by
Reply
Cancel
2 on January 24, 2019

You need to capitalize the ‘U’ in “Update”

 

on January 24, 2019

haha gosh dangit I knew it’d be something stupid, thanks a lot and good eye

Devoted
on January 29, 2019

Good catch. I was searching and searching…

Show more replies
  • Liked by
Reply
Cancel