Hello, i’ve been following Rama’s wiki page on this subject and i’m having the following issue:
##Accessing Custom Character Movement Component
//Inside Character Class
UVictoryCharMoveComp* CustomCharMovementComp = Cast<UVictoryCharMoveComp>(CharacterMovement);
if(CustomCharMovementComp)
{
CustomCharMovementComp->CallFunction();
}
My issue is that CharacterMovement is private on it’s parent class ACharacter, so the wiki page code won’t work.
There is a method used to access it GetCharacterMovement() but it gives me an error when i try to cast it for the child class.
This is my PlayerCharacter.h (child of ACharacter):
FORCEINLINE UPlayerCharacterMovementComponent* GetPlayerCharacterMovement() const { return Cast<UPlayerCharacterMovementComponent>(ACharacter::GetCharacterMovement()); }
I get the following error when i try to compile:
error C2664: 'UPlayerCharacterMovementComponent *TCastImpl<From,To,ECastType::UObjectToUObject>::DoCast(UObject *)': cannot convert argument 1 from 'UCharacterMovementComponent *' to 'UObject *'
2> with
2> [
2> From=UCharacterMovementComponent,
2> To=UPlayerCharacterMovementComponent
2> ]
note: see reference to function template instantiation 'To *Cast<UPlayerCharacterMovementComponent,UCharacterMovementComponent>(From *)' being compiled
2> with
2> [
2> To=UPlayerCharacterMovementComponent,
2> From=UCharacterMovementComponent
2> ]
Anyone can share some insight on this matter? Thanks in advance.