in my project for access a variable in “MyCharacter” from other BP i use get_player_character->cast_to MyCharacter->get var" that work ok but if i change the character and now MyCharacter its “MyCharacter2” and have the same var i going to have a problem. And going to need change all cast_to in my proyect.
my question its, its possible made in someway avoid it.
I’m not sure how they work with blueprints but in code I would use an interface for this. If that doesn’t work as I’d expect I would make MyCharacter2 inherit from MyCharacter instead of the base character class. That way every MyCharacter2 would be a MyCharacter. (Though not the other way around.)
There’s a Blueprint Interface available in the New menu, so play around with that and see if you can have your character blueprints inherit from the base character class and MyCharacterInterface. If so you’re done, cast to your interface and you’ll be able to do anything there with anything that successfully casts. I’ve not yet used this myself, only noticed it in passing.
If not then make one extend the other and cast to that.
Yes, interface is the way to go for your situation.
In fact, try to get all your external access event/functions into interface. (ie. if this event are suppose to be called by another object, make it a interface event/function)
This will reduce a lot of those castTo nodes, and less headach for dependency problems.