What is the industry standard for letting a Blueprint change something in a different Blueprint?

Let’s say I have a tool that I can pick up. Only when that tool is picked up am I allowed to hit the nail.

In that situation you have three different blueprints; the player, the tool and the nail. If you’re using an Interface to trigger events in both the tool and the nail blueprints, at least the nail needs to somehow know whether the tool is being used on it or not.

What is the industry standard for doing something like that?

When they collide / overlap you can detect which things collided

What if you have something that doesn’t collide?

For example if you want a light in the ceiling to turn on when the tool hits the nail.

Tool hits nail sounds like a collision to me

Unfortunately there’s no industry standard. There’s probably dozens of solutions and all that work are somewhat legit. If you ask 5 people then you’d get 5 different answer about how to implement the hammer, the player and the nail.

See what Ulls posted, that’s a few murky examples but as much as you’ll ever get as an industry standard. So namely casting and event dispatchers. Unfortunately there’s no “globals” in UE4. Which means there’s no variable “HasHammerHitNail” that you can configure and access from every blueprint.

There’s some tricks if you really need some “Global” value - with limitations though.

The Level Blueprint can access everything and get references to (nearly) everything. The big drawback? It’s a one way street, so you can’t access the level blueprint from anywhere else.

A pretty nice trick for a “global” variable is the game mode. You can cast to the game mode from pretty much everywhere - so as long as you only have one game mode you can secretly use it as a stash for “global” variables and cast to it whenever needed.

In the end you’ll cast whenever possible as it’s pretty easy to do. You’ll make event dispatchers if you really need them.

And if you’re used to that you might get thoughts like “Does the hammer need to know that it has already hit the nail? Maybe not.”

In the end there are dozens - if not countless - possibilities to program your game. And the big secret? All that work are fine. Industry standard or not…

Thanks a lot for all the responses! This has cleared a lot of things up for me :slight_smile:

I’m quite new to this, coming from a 3D modelling/animation background and being quite paranoid about not creating “unclean” or messy games.

Many schools of thought on this situation, one that I like to follow myself is to create a Function or Interface that would allow the hammer to change the nail’s variables (or vice versa). Having the nail change its own variables, just taking in the information that it needs from the whatever is interacting with it, is a solid (in my opinion) way to go about changing something.

The nail is fed the information on what to change, how to change it, etc. Then the nail decides if it wants to allow the change or not.
The hammer tells the nail what to change, how to change it etc. The nail has to change or fail trying.