Move character with animation using CharacterMoment component

Hello everyone.
I’m trying to make a turn based game on a 3D hexagonal tile based environment. The level data (2D array) will be received from server and then the tiles are spawned using spawn actor function. (server yet to be implemented).

I’m using “Maximo Animation Pack” and spawned one character using BlueprintImplementableEvent and enabled simulate physics on capsule collider component.

UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "SpawnCharacterbyType"), Category = "CharaterSpawning")
APawn* SpawnCharacterByType(FName pCharacterType, FVector pPosition);

and using this function to spawn the character as APawn* and enabling the capsule collider’s simulate physics.

character = SpawnCharacterByType(FName("Mixamo_Adam"),FVector(410.0f, 0.0f, 350.0f));
TArray<UCapsuleComponent*> characterComponents;
if (character != NULL) {
	character->GetComponents<UCapsuleComponent>(characterComponents);
}
else {
	UE_LOG(LogTemp, Log, TEXT("character is null"));
	return;
}
UCapsuleComponent* characterCapsuleComponent = characterComponents[0];
characterCapsuleComponent->SetSimulatePhysics(true);

I googled alot on how to move character and there are many solutions and I tried everything. Character moves but its not doing walk animating. It is behaving like a static mesh just sliding like its position being updated in Tick.

Here are list of things i tried:

Method 1:

Implemented AddActorLocalOffset function in blueprint as BlueprintImplementableEvent and called it inside Tick().

UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "MoveCharacter"), Category = "Move")
bool MoveCharacter( APawn* pCharacter, FVector pDirection, float pValue, bool pIsForce );

Blueprint implementation of this function:

When I run this, character just slide for sometime and falls down. Worst part is character keeps sliding but when he is about to fall he does walk animation. He does animation only when he is falling. I uploaded the video please look at the video.

[Youtube video of character sliding and animating while falling][4]

Method 2:

Everything is same as method 1 expect that this time I used AddMomentInput in MoveCharacter function in blueprint.

90654-capture+4.png

I read that for AddMomentInput to work the character needs to be possessed by a controller. So I did this after spawning the character.

AController* controller = GetWorld()->GetFirstPlayerController();
controller->Possess(character);

But this time, character is not moving at all.

Method 3:

I thought of using the AI navigation system. So I created a NavMeshBoundsVolume and made it very large so that is encompass all the level. In character blueprint I made the AI Controller Class as “AIController”.

I tried moving character using C++ and also blueprints both are not working.
In C++, I creates a function called SimpleMoveToLocation in NavigationSystem.

void ALevelCreator::SetNewMoveDestination(const FVector pDestination) {
	UE_LOG(LogTemp, Log, TEXT("character setting nav points"));
	UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(GetWorld());
	if (NavSys == NULL) {
		UE_LOG(LogTemp, Log, TEXT("NavSys is NULL"));
		return;
	}
	NavSys->SimpleMoveToLocation(character->GetController(), FVector(800.0f, 0.0f, 300.0f));
}

In OutputLog this is what that came.

LogTemp: character setting nav points

LogNavigation:Warning: UNavigationSystem::SimpleMoveToActor called for NavSys:None Controller:None controlling Pawn:NULL (if any of these is None then there’s your problem)

Even in this method, character is not moving at all. Of course with so many values as null its expected that character wont be moving.


These are the three methods I tired. I’m very new to unreal engine and i’m trying to learn the engine. I hope i explained my problem and everything I tried clearly so that you have all info before replying me. Please direct me in direction.

Thanks in advance.

do you want the character to move one tile at a time?

that is gameplay element that i havent decided upon yet. but yes character should be able to move one or two or more tiles. if character can move one tile then i can make him more more than one tile anyway rit?

I’m not sure of a way to get a transform operation to generate velocity. I feel I’ve done this before but I could not quickly replicate it.

One work around is to figure your own velocity. I’ve done this in an animBP by just recording what the previous location was and using that to figure my current velocity.

Also, I just wanted to throw out there the idea of using a VInterp to interpolate between your tile spaces. I like this because it is guaranteed to go from start to finish location without any fuss or clamping. There are many ways to do it but i found this quite simple if simple is what you need. Here it is on Tick but could be a timeline or timer.

@RimmyD thanks for the reply. I tried but the result looks same like what i got in method 1. (watch youtube video attached). character just slided till destination position and then he just fall on his back.

90673-capture+5.png

I dont understand why he falls on back. also after reaching the destination position and falling down on back will he start playing walk animation.

Hey plato, I don’t see a video link anywhere.

Usually this sideways action is because of animation issues (his tpose is fine but his animation has rotation in it). I often see this when someone deletes a node at the beginning of a skeleton heirarchy (like if you had a folder there with some transforms on it in Maya/Max).

This could totally not be this case but maybe know more when i see the vid.

Also can you post your Event Graph and Anim Graph from your Anim Blueprint?

I forgot to mention the video link is in the main post under method 1. Any case here is the link
YouTube video link
I don’t have access to my computer at this moment I’ll definitely post event graph and anim blueprint. I just imported mixamo package never did any changes to anim side of it.

Cool, and can you do a “show collision” in the console and see if the sphyl collision of the character is upright or rotated? Trying to see if what is rotating is the Mesh component or the entire Pawn.

Sorry for such a late reply. I did show collision. It looks like the collider is also rotating. I checked the character’s rotation in the editor and the value is change so the character itself if indeed rotating rit? I set rotation constraint in XY Plane which prevent it from falling or rotating in strange ways but still character is just sliding walk animation is not happening

bump T_T
i’m still looking for answer :frowning: