How do I do movement in a Beat Em Up? (2D movement w/ jumping in a pseudo-3D environment)

I am seriously at my wits end with this. I’m extremely frustrated right now, so pardon the anger.

I can’t figure out how to do this to save my life. I’ve tried everything; I’ve tried tilting the walkable area and making the game 3D, but the damned polygon colliders for my backgrounds won’t tilt with them. I’ve tried making a parent and child rigidbody (the parent for the “shadow” and the child is the sprite which jumps, so I always have a spot on the ground to reference when I jump to check to see if I’ve hit the ground), but not only have I read that this is extremely poor practice, the damned child body, for some reason, can’t pick up the parent’s speed to adjust my animator. I’ve tried to maintain a separate vector for the “ground position” but, in the presence of colliders, these values are not correct. Furthermore, if I print these two values together, the maintained vector eventually accumulates error. I can’t pull these numbers off the rigidbody because the jump throws off the correct y value for the ground. My last recourse was to implement gravity manually, but I don’t want the rigid body to be kinematic. I feel like I’ve seriously tried everything, and I’m on the verge of giving up. I just can’t get the damned thing to run correctly.

Please, if anybody has made a 2D beat em up, please help me. I haven’t been able to find any good information for how to make this work in Unity, and I’m starting to think it just won’t work. If there is any advice, I am sure it will be invaluable to others who are foolish enough to go down this path.

This is the setup I use for movement, it’s borrowed from this Unity game, you can download its assets from the site I believe.

Copypasting the variables declared inside the constructor of the player’s class ( give them the value you prefer, I do that inside Awake()):

	//Movement Variables
	private float xSpeed;								//float to give you a x axis speed
	private float ySpeed;								//as above with y
	private float zSpeed;								//as above with z
	public bool facingRight;							//To check if you are facing right or not; note public, this is
														//useful when you manually set up the scene and you want
														//the player to begin facing Left

This is what I do in Update():

//First, cache input
				float h=Input.GetAxis("Horizontal"); 		//for A D input
				float v=Input.GetAxis("Vertical"); 		//for W S input
				
				float hMove = h * xSpeed;					//When input Horizontal is true, multiply h by moveSpeed
				float vMove = v * ySpeed;					//as above, but referenced to Vertical
				float zMove = v * zSpeed;					//as above, but for Depth

//... Free the speed from framerate's tiranny...
				hMove *= Time.deltaTime;					//this shifts the movement's pace to real seconds
				vMove *= Time.deltaTime;					//as above
				zMove *= Time.deltaTime;					//as above
				
				//This line tells the game what to do with the lines above, that is to Move.
				transform.Translate(hMove,0.0f,zMove, Space.World);

				// ... And animate, referencing to absolute values since negatives would be wrong!
				if(Mathf.Abs(Input.GetAxis("Horizontal")) != 0 || Mathf.Abs(Input.GetAxis("Vertical")) != 0){

					anim.SetBool("MovingInput",true);


				}
				else{

					anim.SetBool("MovingInput",false);
				}
				
				//what about flipping? well, if h>0 you're travelling from left to right...
				if( h > 0 && !facingRight){

					//so you should face right!
					Flip();
				}

				//else...
				if( h < 0 && facingRight){

					//this is the other way around
					Flip ();
				}

This makes the player walk around in x/z axis.

I don’t have a Jump() function so far, I’ve got other stuff though.
Maybe this can help you: it’s one of the many ways one can achieve movement.

The Flip() function is here, this is the coolest thing I’ve learned digging that game I’ve linked to you:

	void Flip(){

		//Many ways to be done, simple one: we swap your bool-facing thing and multiply x scale by -1
		facingRight = !facingRight;
		
		//Time to change your scale, best way is doing it with a method that works both ways around as above...
		Vector3 theScale = transform.localScale;
		theScale.x *= -1;
		transform.localScale = theScale;
		//Thanks Unity staff for this trick
	}

I’m not sure this is exactly what you was looking for but I hope it helps nevertheless. A word of advice though: it’s ok to look chunks of code provided to you, just be sure to also understand their contents and logics… i.e.: copy-pasting is useless without brainpower!

If this is not what you needed, let me know more specifically what is giving you issues, I may know how to help.

P.S.: I forgot to mention that, in order to animate, you need an Animator component and floats declared in that ( I can elaborate this if you need)

My kinematic approach so far hasn’t quite panned out the way I would like, so in the meantime I’m attempting to switch to 3D and incorporate an orthographic camera. From a certain angle, jumping and walking up create the same visual effect and the depth is hidden. Of course, my backdrops are somewhat skewed because of this. I’ll keep everybody up to date about what I’m doing.

I’ve run into another problem now, which I will post in a separate thread…