Question by
joaopedro200384 · Mar 29 at 10:52 AM ·
player2d-platformerenemy
Player automatically jumping off enemy after kiling it.
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<EnemyPatrol>();
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);
}
}
}
Comment