How do I pass the world location of a pawn through an interface

Ok now this makes more sense.

So by that logic, it should be the AI that is looking for a bed, rather than the bed telling the AI where it is. You CAN use an interface, it is not required, but it is decent practice to avoid accumulating dependencies among actors. In this case we can use an interface we’ll call BedInterface, which doesn’t provide any functionality but can be used for filtering actors when AI needs to look for beds. Implement BedInterface in your BP_Bed blueprint :

That’s it. Nothing required in the BP_Bed event graph.

Now you want to tell your AI to look for a bed. I’m not gonna do the full conditional behavior tree for you, just show you the simplest possible approach : a BTTask that seeks a random bed in the level and makes AI move to it.

This should be a starting point.
From that you can expand complexity step by step to reach your desired goals :

  • Add an energy variable in the AI controller, reflected in the BT Tree
  • Add a behavior branch that conditionally takes priority to look for a bed/resting place when energy is low
  • Find nearest bed instead of random
  • Add a boolean variable to the bed blueprint, to keep track of whether bed is free or not, then add interface methods to the BedInterface (and implement them in BP_Bed), to help communication from the AI/BTT blueprint.
2 Likes