rigidbody.MovePosition in More than One Direction

I want to make smooth movements for my characters that have rigidbodies. I tried rigidbody.AddForce, but it’s not the type of movement I want. It’s drags too much, if you know what I mean. So I decided to check out rigidbody.MovePosition. It’s exactly what I’m looking for, but I can only do one direction or the other doesn’t work. Here’s what I have:

//Side-to-Side Movement
	rigidbody.MovePosition(transform.position + Camera.main.transform.right*mh*Time.deltaTime*7);
//Forward-Backward Movement
	rigidbody.MovePosition(transform.position + Camera.main.transform.forward*mv*Time.deltaTime*7);

mh and mv are horizontal and vertical variables that correspond with controller inputs (left & right is mh, up & down is mv). The problem is that horizontal code (which comes first) is being cancelled out by the vertical (last). If I were to switch the order, horizontal would cancel out vertical. How would I make it so that both directions work?

Thanks in advance.

Try adding the forward and right components at the same time and doing a single MovePosition. Also a quick tip: when using rigidbodies, using Rigidbody.position rather than Transform.position will give better results since transform positions are only updated at the end of the physics step.

// Forward, backward, and sideways movement
Vector3 hMove = Camera.main.transform.right*mh*Time.deltaTime*7;
Vector3 vMove = Camera.main.transform.forward*mv*Time.deltaTime*7;
rigidbody.MovePosition(rigidbody.position + hMove + vMove);

haven’t used move position my self , however I do see that you are using “transform.forward” which is a big no no for 2D as it moves u along the z axis(its for 3D) , use “transform.up” instead