[UE 4.10.1] GetCharacterMovement returns nullptr

Hello!

So this is a pretty simple question, yet it’s been bugging me for quite some time.

Even though I was developing my character and kept testing movement and such (everything worked good), all of a sudden the function “GetCharacterMovement()” stopped working, as it returns nullptr!

if (GetCharacterMovement() == nullptr)
	{
		GLog->Log("woah!"); // As you might guess, this runs! It is called in BeginPlay().
	}

Funny thing is, that my custom character (derived from Character Class) actually has a CharacterMovementComponent on him, and if i try to get a reference to it with an iterator, I can perfectly do that!

//The following code works perfectly!
TArray<UCharacterMovementComponent*> Comps;
	GetComponents<UCharacterMovementComponent>(Comps);
	for (int32 i = 0; i < Comps.Num(); i++)
	{
		PlayerAwesomeMovement = Comps[i];
	}

However, the function “AddMovementInput” no longer works for me, and my character is frozen in place forever.

Now, i have checked out this issue, and have found out that the most common roots of the problem are the following:

  1. the movement is not replicated on a server - Check (It is)

  2. the character belongs to a server, and not a client - Check (I am making singleplayer)

  3. there are more than 1 character controllers spawned, and this creates a conflict - Check (Only 1 spawns!)

  4. My Character does not have a “CharacterMovementComponent” - Check (It has!)

  5. Building a custom CharacterMovementComponent in C++ - Check (nope, I am using all the basic one)

Now, do you guys have any idea what could be the source of this problem? Maybe I’ll try building up a custom movement system. It’s just weird as it was working perfectly until I am like 1-2 days worth of actual coding into the prototype.

Thank you for your time into this!

Hey DigitalDok-

Is the code snippet you posted in your custom character class or elsewhere? Are you able to reproduce this in a new project? If so, what are the steps that reproduce the issue?

Cheers

Hello !

Yes, the snippets are in my custom character class.
I have no idea how to reproduce it.

Apparently, this can be fixed if you build it all up again from zero!

Fortunately, I could get further into the development, but unfortunately could not find the reason of this behavior. I’ll just keep in mind not to go that far when editing my new character i guess and test stuff more frequently.

Cheers!

I experience the same issue. It appeared when I removed my custom character movement component to switch back to the default one. Running 4.17.2. How to fix this?
Thanks!