I been following brackleys 2d tutorial.
He said there is a way to flip the enemy sprite, but he has not updated it.
Can any one help me. Here is the code to my enemy.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour {
[System.Serializable]
public class EnemyStats {
public int maxHealth = 100;
private int _curHealth;
public int curHealth
{
get { return _curHealth; }
set { _curHealth = Mathf.Clamp (value, 0, maxHealth); }
}
public int damage = 40;
public void Init()
{
curHealth = maxHealth;
}
}
public EnemyStats stats = new EnemyStats();
[Header("Optional: ")]
[SerializeField]
private StatusIndicator statusIndicator;
void Start()
{
stats.Init ();
if (statusIndicator != null) {
statusIndicator.setHealth(stats.curHealth, stats.maxHealth);
}
}
public void DamageEnemy (int damage) {
stats.curHealth -= damage;
if (stats.curHealth <= 0)
{
GameMaster.KillEnemy(this);
}
if (statusIndicator != null)
{
statusIndicator.setHealth(stats.curHealth, stats.maxHealth);
}
}
void OnCollisionEnter2D(Collision2D _colInfo)
{
Player _player = _colInfo.collider.GetComponent<Player>();
if (_player != null)
{
_player.DamagePlayer(stats.damage);
}
}
}