I have been trying to make the enemy look at the player when the players x position is larger than the enemys but when It trys to look at the player the collider freaks out and then it’s y position starts growing in the negitives really fast
This is the Code:
public class EnemyTexFlip : MonoBehaviour
{
public GameObject player;
public Collider2D enemyCollider;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(player.transform.position.x > transform.position.x)
{
transform.localScale = new Vector3(-1f, 0f, 0f);
}else if(player.transform.position.x < transform.position.x)
{
transform.localScale = new Vector3(1f, 0f, 0f);
}
}
}