[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

Rama

#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

#Robert M. Fixed this here

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