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"

[4.2 Bug/Crash] Cant use custom CPP Character Movement classes in 4.2

Dear Friends at Epic,

I've been happily using a custom character movement all the way through 4.1.1.

But in 4.2 I've now noticed that using the traditional method (first recommended by James G during the Beta, now the CharacterMovement ptr of the Character class becomes invalid!

Even if I manage to access my custom character movement component, which does exist in the world, the Character ignores all movement imput because its CharacterMovement ptr is null!

So there's literally nothing I can do with custom character movement until this bug is addressed

Here's the method I am using:

Character Class

 //////////////////////////////////////////////////////////////////////////
 // AJoyShapesCharacterBase
 
 AJoyShapesCharacterBase::AJoyShapesCharacterBase(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP.SetDefaultSubobjectClass<UJoyMoveComp>(ACharacter::CharacterMovementComponentName))
 {
 
 }
 
     
 void AJoyShapesCharacterBase::PostInitializeComponents()
 {
     Super::PostInitializeComponents();
     
     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     //                        Joy Move Comp
     //Set PC for Move Comp
     JoyMove = Cast<UJoyMoveComp>(CharacterMovement);
     if(JoyMove)
     {
         JoyMove->VictoryPC = VictoryPC;
     }
     
     //No char movement?!?!?!
     if(!CharacterMovement)
     {
         UE_LOG(Joy,Error,TEXT("THE CHARACTERMOVEMENT COMP IS INVALID"));
     }
     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
 }

 
 /*
 
     By Rama
 
 */
 #pragma once
 
 #include "JoyMoveComp.generated.h"
 
 class AJoyShapesPC;
 
 UCLASS()
 class UJoyMoveComp : public UCharacterMovementComponent
 {
     GENERATED_UCLASS_BODY()
 
 //Core
 public:
 
     //Tick
     virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) OVERRIDE;
 
 
 };


Custom Character Movement Class

   /*
     
     By Rama
 
 */
 #include "JoyShapes.h"
 #include "JoyMoveComp.h"
 
 //////////////////////////////////////////////////////////////////////////
 // UJoyMoveComp
 
 UJoyMoveComp::UJoyMoveComp(const class FPostConstructInitializeProperties& PCIP)
     : Super(PCIP)
     {
 
    }

 //Tick Comp
 void UJoyMoveComp::TickComponent(
     float DeltaTime, 
     enum ELevelTick TickType, 
     FActorComponentTickFunction *ThisTickFunction
 ){
     Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
     UE_LOG(Joy, Error, TEXT("Ticking!!!")); //<--- This is working!
     
 }


What Logs Show

My Logs show that the CharacterMovement ptr from the Character.h class itself is indeed invalid after Post Init.

My logs also show that the custom CharacterMovement Component IS actually ticking!

Analysis

Somehow the CharacterMovement ptr is no longer getting updated to the new custom CharacterMovement Comp as of 4.2

This makes things very difficult and also makes the CanJump CPP override crash instantly.

CanJump() crashes the game since no CharacterMovement ptr

 //USEING CUSTOM MOVE COMP MAKES THIS CRASH!!!
 
 //REPORT IF STILL CRASH PRESENT AFTER 4.3 !!!!!
 /*
 bool AJoyMovement::CanJumpInternal_Implementation() const
 {
     return true; // !IsHovering();
 }
 */

Help!

Help!

Related Thread

https://answers.unrealengine.com/questions/23043/custom-pawn-movement-component.html

Rama

Product Version: Not Selected
Tags:
more ▼

asked Jul 12 '14 at 11:26 PM in Bug Reports

avatar image

Rama
10.7k 446 346 1090

avatar image Rama Jul 12 '14 at 11:45 PM

More Info

I did some tests and the custom character movement comp is definitely being created, and knows who its proper Owner is.

But the CharacterMovement ptr in Character.h is not being updated properly to the new custom movement component and is always null!

 //the logs below both are shown, so the movement comp definitely exists, but CharacterMovement is NULL
 
     for(TObjectIterator<UJoyMoveComp> Itr; Itr; ++Itr)
         {
             AJoyMovement* Owner = Cast<AJoyMovement>(Itr->GetCharacterOwner());
             
             if(Owner)
             {
                 UE_LOG(Joy,Warning,TEXT("%s"), *Owner->GetName());
                 
                 if(Owner == this)
                 {
                     UE_LOG(Joy,Warning,TEXT("We found our movement comp yay!"));
                     
                     CharacterMovement = *Itr;
                 }
             }
         }


"we found our movement comp yay!" does show in the log

....

But CharacterMovement of Character.h fame is still NULL

This makes custom character movement components in CPP impossible to use

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

1 answer: sort voted first

Robert M. Fixed this here

https://forums.unrealengine.com/showthread.php?16514-Adding-custom-movement-component&p=95377&viewfull=1#post95377

Link to github to implement fix locally while not yet up to 4.3 / whenever his change is fully brought into the engine.

https://github.com/EpicGames/UnrealEngine/commit/fab71f76b717a9bafbb0b91831ebb44cd73f0f11 Rama

more ▼

answered Jul 14 '14 at 04:21 PM

avatar image

Rama
10.7k 446 346 1090

(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