Announcement

Collapse
No announcement yet.

Static Functions in Blueprint?

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

    Static Functions in Blueprint?

    Is it possible to create and use static functions in Blueprint such as class'PlayerPawn'.static.GetHealth() without spawning an instance of the class?

    #2
    Why would you want to do this?

    This is a bit of an odd question, especially given player health being used as an example.

    Without an instance of the class, mostly the problem would be that any variables would not be initialized.

    I'm not entirely sure of the implementation of the function you described above, i would presume that it uses some form of argument to identify an instance of a player pawn to act on.

    Comment


      #3
      I used a blueprint macro library to emulate a static function:

      Click image for larger version

Name:	singleton.jpg
Views:	1
Size:	14.3 KB
ID:	1050001

      Comment


        #4
        macro is actually more like....macro.
        And Tucarius is right, I don't think you can do static function for blueprint, but you can always create a "static_YourBlueprint" item that you don't use, thus you can still get default value.
        BUUUUUT, there are already people mention how to get/set default values of your variables, so I don't see a point to use a static function to do this.
        Unreal Engine 4 Game Framework diagram for relation of all major base object types
        Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
        Resident Evil Classic Camera
        RPCs official document, Must Read
        Everything you should know about replication

        Comment


          #5
          I was looking for the same solution and finaly came to this: ContentBrowser -> RightClick -> Blueprints -> Blueprint Function Library

          Comment


            #6
            https://forums.unrealengine.com/deve...79#post1414979 the best solution, HawkPride thank you very much!

            Comment

            Working...
            X