Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Player automatically jumping off enemy after kiling it.

$
0
0
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); } } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>