- Home /
Question by
Ceraff · Mar 30, 2016 at 08:55 AM ·
2d-platformervelocitycollider2d
Constant velocity when colliding - 2D
I'm trying to make player jump on death. It works when it falls below -2 (jumps a bit and start falling down), but when i collide with enemy, it doesn't move at all or moves at constant speed when I increase velocity.
public IEnumerator Death()
{
if (myRigidBody.transform.position.y < -2 || collision)
{
canMove = false;
myRigidBody.velocity = new Vector2(0, deathJump);
GameObject.Destroy(GetComponent<BoxCollider2D>());
myAnimator.SetFloat("Speed", 0);
yield return new WaitForSeconds(.6f);
Time.timeScale = .00001f;
yield return new WaitForSeconds(.6f * Time.timeScale);
Time.timeScale = 1;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
I also tried adding Force, but that just skyrockets me in the air.
Comment
Why dont you try making the player look like he is jumping in a death animation and play it when the player dies ??