Graylord
(Graylord)
April 19, 2020, 12:39pm
1
Hi, in my current character class I do this:
AnimInstanceRef = Cast<UCharAnimInstance>(GetMesh()->GetAnimInstance());
To get the animinstance in my character.
But how would I do the other way around? I need to trigger a function in my character class once an animation has ended, but don’t know how to get a reference to my character.
Also, how do I avoid circular dependency? But still be able to trigger functions between the classes?
Create a delegate in your anim instance and then bind to it from your character sounds like the easiest way.
Or create a public function in your character that ypu call from the anim instance. Cast to get owner to get your character.
Graylord
(Graylord)
April 19, 2020, 8:06pm
3
Not sure how to do something like that I’m afraid.
I tried to forward my class in my animinstance header.h like this:
class ATribesmenCharacter;
ATribesmenCharacter* Char;
cpp:
AActor* Char = GetOwningActor();
But the editor crashes when I try to launch it.
Graylord
(Graylord)
August 21, 2020, 9:14pm
4
Sorry for necroing this old thread, but I’m once again needing to do this and couldn’t figure it out last time. Any ideas?
hard_code
(hard_code)
August 21, 2020, 9:25pm
5
ATribesmenCharacter* Char = Cast<ATribesmenCharacter>(this->TryGetPawnOwner());
https://docs.unrealengine.com/en-US/…ner/index.html
Graylord
(Graylord)
August 22, 2020, 11:38am
6
Aaaaaah, thanks I was nearly there, just missing the ATribesmenCharacter* part.