Progress is being made on my Crash clone, but now I’m having bit of trouble with the crate spawner adjacent, i.e. you hit this and it spawns a number of crates. Originally, I had the “Hidden” parameter set up in the construction script, but this caused issues with the other different crate types messing with priority, so I took the code out from construction entirely and placed it in the event graph. What I want the crates hooked up to a switch to do is:
Remove the clear placeholder material I applied to any hidden crate
Restore the collisions that every instance of the master crate BP has
Behave like the variant that I selected for it (e.g. reinforced, indestructible, etc.)
As things currently stand, the switch and container behave as expected, but when I activate the switch, the crates remain transparent and intangible. Anyone know what’s going on with that?
I’m not sure why you’re using the AnyDamage event- it could be confusing down the line. Also, you can move the branch node to right before the delegates- the nodes before that are exact clones.
I’m also very confused about why you’re calling the delegates “DestroySwitchActivate” and “CreateSwitchActivate” rather than “SwitchDeactivated” and “SwitchActivated”. It’s not very clear what the delegates do at first glance.
Unless you’re calling EventBeginPlay from somewhere, it won’t be called. Make sure you’re using BeginPlay. This would cause your CreateSwitchActivate delegate to not be bound to the RevealHiddenContainers event. I assume your RevealHiddenContainers event is the thing that is supposed to make it opaque and tangible.
So what should I be using instead of the “AnyDamage” node? And the reason there’s cloned code is because both switch types have separate materials applied once they are triggered.
Also, sorry for not clarifying this with a screenshot sooner. I do have it linked up to a BeginPlay, it’s just some code for custom gravity is in the way.
Oh yeah- I looked at that but I missed that they were different materials.
Instead of AnyDamage you should probably use a custom interface with an interact function. Unless what you're using to trigger the switch is some type of projectile weapon that's also is used in combat.
You don’t need the branch checking whether the switch is equal to the passed switch on RevealHiddenContainers. That will never be false, assuming you don’t change switches mid-game. You only bind to Switch, and that delegate passes back self, which is Switch. If you do change switches, you should unbind it first.
Speaking of- you’re sure you’ve set the switch right? Make sure to check that the RevealHiddenFunctions call actually triggers.
I also assume you have some tick function that checks whether Hidden is true or not, and adjusts values accordingly. If not, that's the problem. If so, having unneccesary stuff in the tick function is not good from an optimization standpoint, so I would probably more so recommend making a SetHidden(bool Hidden?) function.
I’m afraid the AnyDamage node is necessary since I have a custom damage system set up with hitboxes and everything; I take it out and it no longer works at all. And the switch checker is future proofing for a level that has multiple switches.
But those are moot points since you were right, the EventTick node does indeed solve the collision issue. I can now happily navigate my player character up a staircase of hidden blocks I used as a test for the switch, and they also respond to inputs (i.e. the crates I set to be reinforced only break if I groundpound them). The only issue now is that they still have the transparent material instead of their original opaque ones.
I did what you suggested and split the listen for switch call functionality off to its own separate thing extending from a previously unused tick node, I’ll tidy up the nodes once I can sort the material side out as well
Okay I know the problem for sure this time. Here’s how to fix it. You aren’t reverting the material. To do this statically is a cinch, but to do it dynamically will take a few mode nodes.
In your begin play, you do this after timer and bool set for unrelated things.
First, we cache the original material of the blueprint to be used when resetting. Then, we call the SetHidden function defined later in this response in order to push the default value set by you. Lastly, we bind the switch event.
For the previously mentioned SetHidden function, I would recommend this: