I made a code for killing enemies jumping on them, like in Super Mario, but my Player jumps when he touches the ground, instead of the head of the enemy. This is my code for the enemy:
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
public class Rosa : MonoBehaviour
{
public Rigidbody2D RBRosa;
public BoxCollider2D BCRosa;
private Animator Animator;
private MovimientoGazz Gazz;
// Start is called before the first frame update
void Start()
{
Gazz = FindObjectOfType();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "Player")
{
Gazz.Hit = true;
BCRosa.enabled = false;
}
}
}
↧