Hello. I have 2 BP (day/night system bp and firepit bp). firepit bp has public variable “On?” which control state of firepit (fire on/off). I’m trying to set this variable to true in day/night bp, and it works, but in the game I don’t see any effect. I’ve tried to add more checking steps but it doesn’t help. For now I have this in day/night bp:
Array is not empty, cast isn’t failed, name of bp in print string node seems correct, get “on?” variable shows me the true so it should work.
And this is settings for firepit’s variable:
Seems like I miss absolutely obvious thing but I can’t find out what is it?
Can you show an image of what the Firepit On/Off behavior looks like? The issue might be there.
Sidenote your Cast To BP_Fire_01 is redundant in this case, as you’ve already established your casting to that class via the “Get All Actors of Class” node.
If this behavior is only in the construction script you won’t see it in game. The construction script happens at the time of construction of an object (also in editor whenever an object is moved or a variable is changed).
If you want this to work try moving your code to an event that takes in an input of on off and have your time of day call that. Let me know if this works!
The reason you have no effect is that a variable update alone will do nothing else in the target BP.
So unless youre checking your ON variable all the time nothing will happen.
Rather than keep checking the var, have a public function instead that has a boolean input for the ON. Inside this function run your code to DO whatever swicthing it on does and obviousley OFF also dont forget.
Then run the function from your other BP in the same way by dragging off from your get actor node.
Oh by the way there is a “Get Actor Of Class” (not actors) which will get the 1st actor it finds of the class you want. No need to use a seperate Get node. This may work here if theres only ever 1.
Edit: as @Mep_Joss mentioned a custom event would work here
To keep the construction script and optimise move all the code to a function and allow the custom event and the construction script call the function, best of both worlds
You can keep your code in the a construction script and your event and everything will work as it should just fine.
Or you could consolidate everything to a single function and use that in both the construction script and the event.
Or tie everything to a bool that is buffered on tick and then instead of calling the function you change the bool from the time of day. That would look like: