Why doesn't my 2D character move even though the inputs are working?

I am using 5.2.1 if it makes a difference.
I’m trying to learn to make a 2D game through a tutorial: https://www.youtube.com/watch?v=g31NTpq9p-o&t=617s

I ran into an issue in which he starts to use the old input methods which are depreciated now, so I found another tutorial that specifically talks about how to use the new ones:Creating Character Movement With The New Enhanced Axis Mappings In Unreal Engine 5 (Tutorial) - YouTube

I deviated a bit as he made a 3d movement for a 3d character and I require 2d movement but it’s mostly the same I just removed the camera movement and didn’t make it have forward and backward movement

My current issue is that when I set up the inputs as shown in the second tutorial the 2D character won’t move or jump but the inputs are being done and I know they are functional as I set up a print string for both so I could test if the inputs were being used. I’m unsure what I am doing incorrectly.

the included images show the node setup, and that the inputs are working, but not on the character.



At a glance (judging by the print string output) it seems jumping executes every frame instead of when pressed (or, perhaps, you can mash the buttons that fast). That could prevent the character from moving, indeed.

Could you show how IA Jump is set up?


thats the IA_jump

Since jumping is a singular action (may depend on the game mechanics, ofc), shouldn’t this be:

image

I’m working on 2D game now, and all is good. Here is my setup to help you out.


Please note the Negate modifier here. It’s important



Replace this code with appropriate BP methods

void ADungeonCharacter::HandleWalk(float WalkValue)
{
	if (!InKillSequence())
	{
		CurrentInputValue = WalkValue;
		const FVector ForwardVector = GetActorForwardVector();
		AddMovementInput(ForwardVector, WalkValue);

		if (WalkValue > 0.0f)
		{
			GetSprite()->SetWorldRotation(FRotator(0.0f, 0.0f, 0.0f));
			CrouchCapsule->SetRelativeLocation(FVector(15.0f, 0.0f, 0.0f));
		}
		else if (WalkValue < 0.0f)
		{
			GetSprite()->SetWorldRotation(FRotator(0.0f, -180.0f, 0.0f));
			CrouchCapsule->SetRelativeLocation(FVector(-15.0f, 0.0f, 0.0f));
		}
	}
}
void ADungeonCharacter::JumpPress()
{
	if (!InKillSequence() && IsOnTheGround())
	{
		Jump();
		ChangeTheAnimation(Jumping);
	}
}

is the movement component modified in any significant way?

Do you actually get to jump? And the next thing, what values do you get when you print this:

Also, I followed this tutorial. He has bunch of smelly code there, unfortunately, but at least he explains good on how to use enhanced input.

Do you actually get to jump? And the next thing, what values do you get when you print this:

I also think he should use GetForwardVector() here :slight_smile:

I don’t work with 2D often. And the characters are weirdly rotated, mix in Control Rotation and I’m lost. Chances are we’re moving in the wrong direction and cannot get off the ledge.

you use a “handle walk node” i dont even have that as an option.

character movement is default

I don’t work with 2D often. And the characters are weirdly rotated, mix in Control Rotation and I’m lost. Chances are we’re moving in the wrong direction and cannot get off the ledge.

Me neither, just started new game after finally finished my old one. But, as far as I see, he should use GetForwardVector(). I use it in my code, and all is good. It is quite logical that you need it, because movement component calculates forces of the movement.

the tutorial i followed did have forward vector but they used it for forward and backward 3d movement, they used right vector for horizontal movement so i figured it should work for 2D as i don’t currently want the 2D character to have depth movement.

the tutorial i followed did have forward vector but they used it for forward and backward 3d movement, they used right vector for horizontal movement so i figured it should work for 2D as i don’t currently want the @D character to have depth movement.

Follow up on the tutorial I’ve provided here, or look at the images i’ve sent, and it should work. I use same engine version, and it works just fine. And I also work on 2D game now. Just trust me :slight_smile:

  • can you show us the char sitting in the scene?

image

So we can understand the direction needed.

  • since you’re attempting to use Control Rotation, is the char actually using it:

And, since it’s in use, how are you setting it?

  • what values are you getting out of these:

  • try using actor right vector or actor forward vector and see if you can get the Fox to move

for your node setup you have “handle walk”, I don’t have that listed in search as an option, I also do not have “Jump Press” they might be renamed but still I don’t specifically have those

“Do you actually get to jump? And the next thing, what values do you get when you print this:” no I do not, character does not move at all and as for values I don’t know

You have code snippets bellow. But no matter. Use these

image

Ok Bojan I’ll test and report back

1 Like

OK, but please make sure you setup your InputActions and InputMappings as I have. You have all my setup details above.