I’m somewhat experienced with coding, but new to blueprints. Let’s say I’ve got an input key like ‘e’ that sets a variable. Now how do I tell a second blueprint to fire when this variable is updated or when the input key ‘e’ is pressed and then use that variable?
It works with using an event tick in the second blueprint, but this seems highly unoptimized as it will set the variable every single tick and in my experience with general coding there should be a far easier way.
There are so many ways to communicate between Blueprints, so it’s hard to suggest you one way. It all depends on the situation. Tick in this case is not a good solution for sure.
For example you can save an object to a variable and then you can use functions from that object.
Another way are Interfaces: Implementing Blueprint Interfaces | Unreal Engine 4.27 Documentation | Epic Developer Community
But it’s a little bit generic question, so it’s hard to be precise with an answer.
As for inputs, you have the whole system to setup them, so you don’t need to check on tick if E is pressed, I hope you used this?
Oh and you touched one more thing, actually there is no an easy way to check if a variable was updated. So rather use events and delegates (event dispatchers) if you want a logic to happen on some “change”.
So far I’ve tried this diligently with interfaces, but if not updated every tick I couldn’t get it to update variables in different blueprints. Key inputs/ enhanced input actions also don’t seem to fire when used outside the player character pawn. Event dispatchers are new to me and seem to be exactly what I’m looking for, especially in combination with interfaces and casting.
All communication methods require you to obtain a reference to an instance you wish to talk to. It’s never about casts, interface, direct. It’s all about knowing where the actor instances are.
If you have ref, everything (even Event Dispatchers, below) becomes trivial: