x

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"

Character is not moving

I have some serious issues with implementing custom movement modes or states, I searched on the forums and I don't quite get how people is managing to implement their custom movement modes. I followed rama's tutorials and I feel them some incomplete, and I found the topic itself a little bit confusing and hard to implement.

So I want to create a new movement state for my character, what I want to do is to change movement state to CUSTOM from character.cpp that state will call a function of my custom movement component class, the code works, the communication between classes is working, but the character is not able to move. Here is my code:

MOVEMENT COMPONENT.H

 enum ECustomMovementMode
 {
     CMOVE_WallRunning     UMETA(DisplayName = "Wall Running"),
 };
 UCLASS()
 class UWallRunMovComp : public UCharacterMovementComponent
 {
     GENERATED_BODY()
 
 
 public:
 
         TEnumAsByte<enum ECustomMovementMode> NewCustomMovementMode;
 
 
         APlayerCameraManager* GPCM;
         APlayerController* PC;
         
         FHitResult CT_OutHit;
         FCollisionQueryParams TraceParams;
 
         FTimerHandle WallRun_Clock;
 
         UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WallRun)
             float TimeOnWalls;
 
         UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WallRun)
             float DistanceTolerance;
 
 
 protected:
     virtual void PhysCustom(float deltaTime, int32 Iterations) override;
     UWallRunMovComp(const class FObjectInitializer& ObjectInitializer);
     void VWallRun(float deltaTime, int32 Iterations);
 };


MOVEMENT COMPONENT.CPP

 UWallRunMovComp::UWallRunMovComp(const class FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
 { 
     TimeOnWalls = 3.f;
     DistanceTolerance = 150.f;
 }
 void UWallRunMovComp::PhysCustom(float deltaTime, int32 Iterations)
 {
     switch (CustomMovementMode)
     {
     case CMOVE_WallRunning:
         VWallRun(deltaTime, Iterations);
         break;
     default:
         break;
     }
 }
 
 void UWallRunMovComp::VWallRun(float deltaTime, int32 Iterations)
 {
     this->GPCM = UGameplayStatics::GetPlayerCameraManager(this, 0);
     this->PC = UGameplayStatics::GetPlayerController(this, 0);
     GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Yellow,"lol");
     
 }
 

CHARACTER.CPP (Only function that changes movement mode)

 void ARunnerCharacter::V_WallRun()
 {
     if (GetCharacterMovement()->MovementMode == 3)
     {
         UWallRunMovComp* CustomCharMovementComp = Cast<UWallRunMovComp>(CharacterMovement);
         if (CustomCharMovementComp)
             GetCharacterMovement()->SetMovementMode(MOVE_Custom, CMOVE_WallRunning);
     }
     
 }

the build compiles succesfully and when I Jump and press the "special" input keys, the game is printing the string "lol" just to make sure it works, I have some custom code there to perform the movement which compiles correctly too, but the character is just standing in the air doing nothing, I can shoot and look around but I can't move or jump, I am able to crouch too (Custom crouch but not in a custom movement mode)

¿What am I doing wrong?

Thanks

Product Version: UE 4.9
Tags:
more ▼

asked Oct 27 '15 at 01:19 AM in C++ Programming

avatar image

Georgespartan01
192 19 22 80

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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