Download

Problem with Setting a Boolean Variable

I seem to be having issues with setting Boolean variables.

I’m a newbie to the forums and need help with one of my projects. I was programming a simple platform that would disappear when an AI touched it, and make a trophy appear when the platform is destroyed. The problem is, that in the platform blueprint, the variable for whether the AI is touching the platform won’t set to true. When I run the game, the platform gets destroyed but the trophy remains invisible. What can I do to set the boolean variable to true? Or have I coded it incorrectly?

In addition, am I referencing the trophy object correctly in the casting node (first blueprint) because I’m not sure it looks correct as there is a warning.

Any help is appreciated. Thanks for reading!

Platform Blueprint:
BP1.PNG

Trophy Blueprint:
BP2.PNG

A couple of things to point out here.

First of all, you should not need Tick in this context, and the way you are using GetAllActorsOfClass on Tick like that is bad practice.

Your Warning on the CastTo node is because your GetAllActorsOfClass node is already returning a list of Trophy2 objects, so you dont need to cast again, it is redundant. The compiler will tell you this, the warning will be explained by the compiler.

Another thing, you shouldnt pull references to Objects from other execution paths, its bad practice and can lead to problems. Infact that is exactly why your variable is not being set correctly. The context of the Tick execution is seperate to your Set nodes execution path.

You should be able to accomplish all your asking on the Event ActorBeginOverlap.

Thank you so much! I didn’t think it was that easyl! Thanks for helping!

Final Blueprint:
BP3.PNG