I want my player to after jumping on top of an enemy he kills it and jumps ups at the same time. I already did the killing part, but i cant figure out how to make him jump.
here is the code i have on the enemy
[SerializeField] GameObject Inimigo;
[SerializeField] Animator Morte;
[SerializeField] private Rigidbody2D Jogador;
public float bounce = 5f;
private void OnCollisionEnter2D(Collision2D collision)
{
EnemyPatrol enemy = collision.collider.GetComponent();
if (enemy != null)
{
foreach (ContactPoint2D point in collision.contacts)
{
if (point.normal.y >= 0.9f)
{
Jogador.AddForce(new Vector2(0f, bounce));
}
}
}
if (collision.gameObject.tag == "Player")
{
Morte.SetTrigger("Morte");
Destroy(Inimigo, 1);
}
}
}
↧