Announcement

Collapse
No announcement yet.

Doubt about Targets for Function Calls

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

    Doubt about Targets for Function Calls

    Hey everyone, I'm a student trying to learn Unreal.

    I've been trying to understand how to target certain class objects when you're calling a function of theirs in another blueprint. For instance, if you've implemented a function in the game mode event graph (via a blueprint interface), you have to target the game mode when calling that function from another class blueprint.
    What do I do if I've implemented a function in a character blueprint? I've made a BPI for that character and implemented the function, but I'm unable to get a reference to the object when I'm calling that function from another class.

    #2
    There is many ways to get a reference.
    You have to be more specific about your set up...
    If you're trying to get a reference of the player Character in a SinglePlayer context, just "GetAllActorOfClass"(PlayerClass) and "Get Copy"(0) should be good.
    In a multiplayer context, you'd have to think more
    GitHub Repo - WIP RPG

    Comment


      #3
      Originally posted by silik1 View Post
      There is many ways to get a reference.
      You have to be more specific about your set up...
      If you're trying to get a reference of the player Character in a SinglePlayer context, just "GetAllActorOfClass"(PlayerClass) and "Get Copy"(0) should be good.
      In a multiplayer context, you'd have to think more
      Hey again Silik. Thanks for stopping by to help. I currently have an Enemy class with a Damage function, which will reduce the enemy's HP by whatever input is provided to it.
      I've also got a Spell class, which has to call this function each time it collides with an Enemy. What would you recommend for this?

      Comment


        #4
        You got "EventHit" on the projectile side and "OnHit" in the receiving side, each provide a good bunch of references.
        GitHub Repo - WIP RPG

        Comment


          #5
          Hey please check out my screenshot. I'm just trying to understand how this works.

          Comment


            #6
            I tested like that:

            Projectile implementing the Interface with SphereCollision Blocking Pawn:
            Click image for larger version

Name:	Interface_Projectile.png
Views:	1
Size:	68.1 KB
ID:	1673030

            ThirdPersonCharacter Implementing same Interface:
            Click image for larger version

Name:	interface_Victim.png
Views:	1
Size:	48.9 KB
ID:	1673031
            GitHub Repo - WIP RPG

            Comment


              #7
              Originally posted by silik1 View Post
              I tested like that:

              Projectile implementing the Interface with SphereCollision Blocking Pawn:
              Click image for larger version

Name:	Interface_Projectile.png
Views:	1
Size:	68.1 KB
ID:	1673030

              ThirdPersonCharacter Implementing same Interface:
              Click image for larger version

Name:	interface_Victim.png
Views:	1
Size:	48.9 KB
ID:	1673031
              Yeah I accidentally left out the Get Class node. My bad.
              Also, I just realised one more thing. All my spells have different kinds of colliders, but I want my parent class to handle the damage dealing functions upon colliding with my enemies. How would it be possible for me to do that? My root component is just a scene, and if I add a collider to my parent class, the child classes will have it too, which I don't want. I can't think of any workarounds for that either. I'd have to have the collider in my parent class to handle collisions if I want my damage dealing functions invoked there, right?

              Comment


                #8
                Why do you want your spells to have different collider?
                GitHub Repo - WIP RPG

                Comment


                  #9
                  Originally posted by silik1 View Post
                  Why do you want your spells to have different collider?
                  They all have different shapes and sizes, which is why I want them to have different colliders.

                  Comment


                    #10
                    Why not make one master spell and change the size of the collider in the children spells?
                    GitHub Repo - WIP RPG

                    Comment


                      #11
                      Originally posted by silik1 View Post
                      Why not make one master spell and change the size of the collider in the children spells?
                      Because I've also used different types of colliders in certain spells. Is there no way around my problem?

                      Comment

                      Working...
                      X