Is there an alternative function to AddMovementInput? UE.2.0

AddMovementInput doesn’t work on client side.
None of its variants work.

AddMovementInput()
AddInputVector();
Internal_AddMovementInput();

I need to move the characters of the clients or I can’t work.

What other function can I use?

Thank you so much!!

Very well done Epic. You broke the movent and you also broke the replication on the client side.

Great way to break a game that works perfectly in the previous version.

I’m seriously thinking about downgrading.

With this you can move on the client side if you have the same problem as me and want to test.

Every time a new version of the engine comes out I have some unpleasant surprise.

Thanks for making my life more difficult.

In 5.2 try creating a fresh project with a character and choose c++ when generating it.
It replicates to client side via the Move function which uses AddMovementInput successfully.


void AMyProjectCharacter::Move(const FInputActionValue& Value)
{
	// input is a Vector2D
	FVector2D MovementVector = Value.Get<FVector2D>();

	if (Controller != nullptr)
	{
		// find out which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get forward vector
		const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	
		// get right vector 
		const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

		// add movement 
		AddMovementInput(ForwardDirection, MovementVector.Y);
		AddMovementInput(RightDirection, MovementVector.X);
	}
}

Are you using the built in movement components or are you planning on replicating variables yourself through GetLifetimeReplicatedProps?

Hi 3dRaven:

I just opened a new 3rd person C++ project in UE5.2 and the replication works on the client side as well. And the movement functions too.

So… I’m using the character movement component that comes by default in the ACharacter class for my project.

However, I’m also using GetLifetimeReplicatedProps too, not to replicate the movement, but to replicate some variables.

Is that the problem? Can’t be use the character movement component and the GetLifetimeReplicatedProps together? Or if you use them together then you should use GetLifetimeReplicatedProps to replicate the movement?

I am very confused right now.

Thank you very much for your help 3dRaven

I did some tests but I don’t get any positive results.

-First I changed the movement functions as they are in the third person example. (same as in your comment).

-Then I temporarily stopped using the GetLifetimeReplicatedProps function.

This does not works.

So I implemented my own character movement component class following Lyra’s example.


It didn’t work either.

I got gravity to work when I put the SimulateMovement function inside the OnTick Event. Otherwise gravity doesn’t work either.

However the movement still doesn’t work.

I have this warning in the constructor of my Character class.


I’ve been reading about virtual function calls in constructors and it seems that this can cause problems. So I commented it out and activated it from the blueprint.

I even deleted the blueprint and created a new one in case it got corrupted during the migration. But this didn’t work either.

I don’t understand what is happening… on the server side everything works correctly. But on the client side the movement doesn’t work.

Any ideas?
Thank you so much!!


VIDEO 1


Look at this:
The client can’t walk, though if he can turn, the turning movements aren’t replicated either…


VIDEO 2


I don’t know if this is related to the other issue.
The point is that pawns placed in the world are not automatically posses on the client side either.


I have this warning while initialization…
Can it be related to it?


I think that warning is the fault of the online subsystem

1 Like

If the AddMovementInput function and its variants are not working on the client side in your game, there are a few alternative options you can try to move the characters of the clients. Here are a couple of suggestions:

  1. SetActorLocation: Instead of relying on the AddMovementInput function, you can directly set the location of the character on the client side using the SetActorLocation function. This allows you to move the character to a specific location in the game world. You can calculate the new position based on the current position and the desired movement direction, and then update the character’s location accordingly.
  2. ApplyImpulse: Another option is to use the ApplyImpulse function to apply a force or impulse to the character. This can simulate movement by adding a force in the desired direction. You can calculate the desired movement direction vector and apply the impulse to the character’s physics body to make it move.

Here’s an example of how you can use the SetActorLocation function to move the character on the client side:

// Get the current location of the character
FVector CurrentLocation = GetActorLocation();

// Calculate the desired movement direction
FVector MovementDirection = FVector::ForwardVector; // Replace with your desired direction

// Calculate the new location based on the movement direction
FVector NewLocation = CurrentLocation + MovementDirection * MovementSpeed * DeltaTime; // Adjust MovementSpeed as needed

// Set the new location for the character
SetActorLocation(NewLocation);

Remember to adjust the movement speed and direction calculation based on your specific requirements. Additionally, you may need to ensure that the movement code is executed on the client side and properly replicated to other clients or the server, depending on your network setup.

It’s important to note that the approach to character movement may vary depending on your game engine and specific implementation. The suggestions provided here are generic examples, and you may need to adapt them to fit your game’s architecture and requirements.

Please refer to your game engine’s documentation or community resources for more specific guidance on character movement in your particular environment.

1 Like

It will be very useful to test my project.

I think for some reason the movement component is not working on the client side. And that’s why AddMovementInput() doesn’t work either. i think so now…

I checked my setup with a new 3rd person project and everything seems to be the same.

The only difference is that mine must have an error somewhere and that’s why it doesn’t work.

Thank you very much for your help

Now i know 100% that the problem must be in my character class.
I uninstalled all plugins except OnlineSubsystemNULL and the problem persisted.
Then I imported the character from the example project and everything worked fine.

So the problem must be one of the components of my character class.
A really weird bug…

It only remains to comment on everything and review one by one.

Thank you very much for your help!!

Hi 3dRaven!!
Please, can you look at this code?

I was looking for the error in my code. I was making the code from scratch. I only put a small amount of code and suddenly the error appears.

However, it seems that it has nothing to do with the logic of my game, nor with my actor components.

I think it is related to the input (UEnhancedInputComponen)

void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)

And/Or with the replication of variables

void GetLifetimeReplicatedProps(TArray &OutLifetimeProps) const

However it seems to be something completely random.
I couldn’t isolate it.

I commented a few lines and suddenly it disappears. Then I uncommented them and it did not appear again

Maybe you can see if I’m doing something wrong.

Because I updated the Engine to version 5.2 a couple of days ago, and suddenly I see a warning that the input system was deprecated. So I updated it and all the problems started.

There is some commented code.

It is what I was discarding until the error disappeared.

The weirdest thing is that the error disappears when I comment out the BeginPlay() and Tick() functions and curiously i’m not using them.

It’s all very weird…

So if you can take a quick look and let me know if you see anything that shouldn’t be that way that would be great.

MyCharacterBase.cpp (13.3 KB)

MyPlayer.cpp (11.0 KB)
MyPlayer.h (4.3 KB)

MyCharacterBase.h (5.3 KB)

Thank you very much 3dRaven!!

Well I got it to compile after some code housecleaning

Ivan.zip (23.9 KB)

Could it be that you are missing the cpp implementation of your interface?

I commented out #include "Global/OutputMessage.h" (I’m guessing it’s a static library)

Hi 3dRaven
Sorry, I thought those missing files wouldn’t matter.

The replica variables and the interface (Character movement Interface) is only for controlling the animations (Anim instance)… it is not used for physical movement.

CharacterMovementInterface.h (2.2 KB)

And OutputMessage.h is just to simplify Log messages. It’s not important too.

OutputMessage.h (1.2 KB)

And MyCollision is just a class to redefine the collision channels (Just to have a recognizable name).

class MyCollision
{
public:
struct FChanel
{
inline static ECollisionChannel Projectile = ECollisionChannel::ECC_GameTraceChannel1;
};
};

I thought that would not be important either.

I will try to locate the problem today too. (for the third consecutive day). If I can find out what it is, I’ll tell you.

Thank you very much for trying!!!

SetReplicateMovement should work.

I’m doing it from the blueprint. It seems that calling virtual functions from the constructor is problematic.

In any case, the replication works perfectly… Only there is something that suddenly breaks everything… without that something everything works fine.

I will fight!! :slight_smile:
If I lose the battle I’ll do a downgrade… I don’t rule out the possibility that it’s a bug in the engine… maybe in the previous version there isn’t this problem.
Thanks 3dRaven!!

Do you have an override in UCCharacterMovement?
in .h

virtual void SetReplicateMovement(bool bInReplicateMovement) override;

and cpp

void UCCharacterMovement::SetReplicateMovement(bool bInReplicateMovement) {
Super::SetReplicateMovement(bInReplicateMovement);
// your extra movement code
}

I didn’t
Should I do it?

try it

ok i will
Thank you!!

Ivan2.zip (54.8 KB)

Replicated movement on your character class. Used engine assets so it should be lightweight.

If you want your own movement component that you added in the constructor to drive it then override GetCharacterMovement() to return your class.

1 Like

Yeah, I think I’ll implement my own CharacterMovementComponent class just to keep things better organized.

I didn’t see any relevant change when I overrode the SetReplicateMovement() function… everything stayed the same.

Thank you so much for this new example. I’m going to test it.

Do you remember the video I sent you by mail?
Everything seems to work fine, right?

OK, I found this in the log:

[2023.06.10-23.53.34:657][721]LogWorldSubsystemInput: UEnhancedInputDeveloperSettings::bEnableWorldSubsystem is false, the world subsystem will not be created

I went to /Project Settings/Engine-Enhanced Input/
And set that option to true.

Ok, well, everything broke again.

If I put that option in false it does not revert to the previous state… Everything is permanently broken…

I didn’t make any changes to the code. This is so crazy.

It seems like something completely random.
I’m not sure, but I think the chances of it being an engine bug are very high.

Are there other people with similar problems in the forum? Or am i the only one?

Thank you very much 3dRaven!!