Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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). alt text 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);

alt text 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) {
 else {
     UE_LOG(LogTemp, Log, TEXT("character is null"));
 UCapsuleComponent* characterCapsuleComponent = characterComponents[0];

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: alt text

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

Method 2:

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

alt text 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();

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". alt text 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"));
     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.

Product Version: UE 4.11
capture.png (339.5 kB)
capture 1.png (115.1 kB)
capture 2.png (56.3 kB)
capture 3.png (152.8 kB)
capture 4.png (47.1 kB)
more ▼

asked May 15 '16 at 03:10 PM in Using UE4

avatar image

82 11 11 22

avatar image Zarkopafilis May 15 '16 at 03:20 PM

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

avatar image plato.manchi May 15 '16 at 03:25 PM

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?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

bump T_T i'm still looking for answer :(

more ▼

answered Jun 24 '16 at 04:03 PM

avatar image

82 11 11 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

alt text

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. alt text

movetest1.png (149.5 kB)
movetest2.png (202.7 kB)
more ▼

answered May 15 '16 at 04:07 PM

avatar image

2.6k 98 16 97

avatar image plato.manchi May 15 '16 at 04:29 PM

@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. alt text 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.

capture 5.png (152.4 kB)
avatar image RimmyD May 15 '16 at 08:18 PM

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?

avatar image plato.manchi May 16 '16 at 12:24 AM

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.

avatar image RimmyD May 17 '16 at 03:19 PM

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.

avatar image plato.manchi Jun 10 '16 at 05:56 PM

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

alt text

capture.png (171.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question