Monday, July 27, 2015

Moving Code Between Blueprints is Hard

The first step I'm taking in my plan outlined below is to move a bunch of my blueprint code out of the level blueprint and into a new PlayerController blueprint class I just made that derives from my custom native one.  A few notes on why this was harder than it should have been:

  • I had to update my DefaultPlayerController class in the Game Mode.  To do this, I look up the blueprint by path.  That path ended up being "/Game/Blueprints/TacticsGamePlayerControllerBlueprint". Apparently "/Game" maps to the root of my project, but I'm not sure how I was supposed to know that.
  • Despite the UI suggesting you can do it, copy and pasting large chunks of Blueprint code is not a good idea.  Nodes that don't have meaning (i.e. local variables or functions that don't exist in the destination) are simply removed.  This makes it very difficult to know which nodes you need to fix up -- I would've rather they import in and are disabled.
  • Some part of the native code change I made broke the Get node to my "Targeting State" property. It refused to treat it as an Enum in any of the nodes where I used it, calling it a Byte instead.  Deleting them and re-adding them fixed it.  Strikes me as some kind of bug.
  • I'm not sure if this is the case, but I suspect you can only have references to level objects from within the level blueprint.  That's reasonable. I had relied on that a bit, so I'll need to restructure  it such that the level blueprint passes those references into the player controller.  For now I just disabled the 1-3 hotkeys to select characters.
With those three obstacles out of the way, I'm now right back to where I started... but with cleaner code! :)

No comments:

Post a Comment