- Home /
Jump functionality for a 2D Top Down game?
Hi, I am struggling to find an efficient way to let my player jump in a 2D Top Down world. I can see a lot of tutorials about platformer views where the camera is oriented at the side of the player, but nothing really working for a top down view like startdew Valley.
I am not using physics, so I move the character on the tilemap using a Couroutine which moves the player to the next position on grid, like this:
private IEnumerator DoMove(Vector3 newPos)
{
isWalking = true;
while ((newPos - transform.position).sqrMagnitude > 0)
{
transform.position = Vector3.MoveTowards(transform.position, newPos, moveSpeed * Time.fixedDeltaTime);
yield return null;
}
transform.position = newPos;
isWalking = false;
}
Is there anybody which give me an hint on how to add a jumping feature ( ideally with animation support?) I am kind of running out of ideas.
Answer by Dailyalex · Jan 14 at 02:49 PM
There is great tween engine DOTween they have already implemented jump functionality: please check method DOJump for Transform (not physics). There is DOJump implemented for rigidbodies as well.
I would like to avoid any additional library. Would be nice to come up with a script which uses Unity library only.
can I ask why? Why you want to invent wheel? If you really want to do it your self, I just googled it and opened first link: https://gamedevbeginner.com/how-to-jump-in-unity-with-or-without-physics/ Hope you will avoid headache..