I have a third person Character. I want to attach an ActorComponent to my Character.
In ActorComponent.cpp
I want to get the rootComponent(or simply the character itself) of the Actor its attached to.
Then I want to get the SkeletalMesh and from this I want to get the AnimInstance .
So my code looks like this:
//AActor * rootComponent = GetOwner();
ACharacter* myCharacter = Cast<ACharacter>(GetOwner());
USkeletalMeshComponent* CharacterMesh = GetMesh();
UAnimationInstance * AnimationInstance = Cast<UAnimationInstance>(
CharacterMesh->GetAnimInstance());
check(AnimationInstance != nullptr);
check(CharacterMesh);
auto Mesh = CharacterMesh;
Thats the error I get:
error:
use of undeclared identifier 'GetMesh'; did you mean 'GetDesc'?
USkeletalMeshComponent* CharacterMesh = GetMesh();
^~~~~~~
GetDesc
note:
'GetDesc' declared here
virtual FString GetDesc() { return TEXT( "" ); }
error:
no viable conversion from 'FString' to 'USkeletalMeshComponent *'
USkeletalMeshComponent* CharacterMesh = GetMesh();
Can someone help implement my idea. Thank you!