How to create an object referance via a blueprint interface?

I have my BP_Player Blueprint, and I want to be able to make a reference to it so that I can access the variables inside of it, but I do not want to use a hard reference (so no cast to BP_Player).

I want to use a blueprint interface, but I don’t know how to attach my BP_Player as an object reference and then use that Object reference in other blueprints to access the BP_Player reference itself (kind of like cast to BP_Player) and get variables stored inside BP_Player (kind of like as BP_Player).

I’ve tried adding the put of my interface to be the Object reference of BP_Player, but that does not seem to work, and I’m kind of confused.

A picture would be nice, or a video (I’ve already looked at many YouTube videos on blueprint interfaces, so please don’t send me those).

First if you want to get stuff from a BP, we need to use Output interface.
Let say our goal is to be able to get the HP of the player from any other BP.

  1. We create our interface and function name GetPlayerHP

  2. Add our interface in our bp player since we want to get the hp from him

  3. We assign the actual HP to our interface function

  4. We can call our function interface with an object that has a relation to our BP_Player, if it your main character playable, we can use GetPlayerCharacter like this:


    Or use with an overlap event with the correct object ref Actor:

Hint:

  • Always call the function with the name (message)., with the letter icon.
  • calling an output function, will have the pin on the right side. (just like we create a custom event with output param)
  • if the target object is of colour yellow, it most likely bad.
  • object ref should be related to the correct object, just keep in mind, BP_Player inherit from Character and, Character inherit from Actor etc… that why we can store them and get the correct ref this way.
1 Like