Good way to change variable type?

Every now and again I need to change the type of a variable. Let’s use an example where I want to change it from MyCustomBPActor to a vanilla AActor.

Changing the type seems to break all links where that variable was used which can be very tedious to search down.

Right now I’m writing this because I found a bug caused by a missing link from a variable I changed the type of two days ago.

Question: Is there a good way to change a variable type?

Prefered solution: My ideal solution would be that the engine didn’t break links, but generated errors for the ones that were not valid with the new type.

This doesn’t directly solve your issue, but if you right click on the variable that has changed and click Find References in the menu that appears, you’ll be able to see all the locations where that variable occurs to check their links. It’s still work but a lot less tedious than scouring BPs.

So then:

  • Create new variable of new type
  • Go through reference list and replace all uses with the new variable
  • Delete the old variable
  • Rename the new variable if desired?

Certainly would be better than doing what I did and hoping to find the now missing links.

But changing type in C++, C# etc is way easier :slight_smile:

You could. Or, if you’ve got variable “MyCharacter” all over the place:

  • Just change MyCharacter from type MyCustomBPActor to AActor
  • Compile, say yes to Unreal complaining about breaking links
  • Find references of MyCharacter
  • Relink each (or update subsequent nodes for things like casts)

That’s what I end up doing.

That would be better!