Announcement

Collapse
No announcement yet.

Getting actor reference in Actor Component?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting actor reference in Actor Component?

    Hello! I am having an issue getting a reference to an actor in an ActorComponent class... I try to use

    Code:
        APawn* Pawn = TryGetPawnOwner();
        AZephyrCharacter* Character = Cast<AZephyrCharacter>(Pawn);

    I have used this method inside of an AnimInstance class, and it works successfully. I have added #include
    Code:
    "ZephyrCharacter.h"
    #include "GameFramework/Pawn.h"
    To my header file for the ActorComponent as well.

    Any help would be greatly appreciated!

    P.S. I noticed you can not even use the TryGetPawnOwner node in a ActorComponent blueprint either... There must be a way?

    #2
    Simple:

    Code:
    auto myPawn = Cast<APawn>(GetOwner());
    "I have harnessed the shadows that stride from world to world to sow death and madness."

    Comment


      #3
      Ah! Feeling like an idiot. Thanks so much EvilCleric!

      Comment


        #4
        It's important to invest some minutes a day into reading Game Framework classes in source and/or API online pages.

        You make yourself more familiar with what the engine can do and when the API changes it's easier for you to know where and what you have to refactor in your code.
        | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

        Comment


          #5
          Originally posted by BrUnO XaVIeR View Post
          It's important to invest some minutes a day into reading Game Framework classes in source and/or API online pages.
          Hmm. Which game framework should I have looked up? Actor component?

          Currently reading Tom Loomans Game framework c++ guide!
          Last edited by Darkloud1989; 03-19-2020, 11:59 AM.

          Comment


            #6
            https://docs.unrealengine.com/en-US/...ork/index.html
            | Savior | USQLite | FSM | Object Pool | Sound Occlusion | Property Transfer | Magic Nodes | MORE |

            Comment


              #7
              You have no idea how many dots you just connected for me... Thank you SO much... I have a lot to learn.

              Comment

              Working...
              X