Cannot set hidden in-game

I have this laser on enemy that is going to activate after 1 second if i step on a box volume. when im in it slows me down and a sprite of the laser appears. this is ok. now when i get out of it my move speed is back to normal (also ok) but when i say it to set hidden the sprite in game, it doesnt do it. it casts prefectly fine to the laser but it doesnt set it hidden in game. why is that? i will show some screenshots of this.

i put to print a string on the cast failed which will show on the top left of the screen

Hello GitGudGitRekt,

Is the logic that you showed in the Player’s BP or in the other BP that the collision box is contained in? If this is not in the Player’s BP, then the reference that you’re getting from the “Other Actor” pin is a reference to the player’s character and not the laser. You’ll need to get a reference to the laser some other way. This is not working due to the cast failing, you can see that from the print string.

Ok so you if i connect the cast function to other actor, im doing it to the player character as you said. then what should i connect the object node to?

If you’re casting to the TankFreezingLaser class, the reference that you plug into the object pin needs to be of the TankFreezingLaser class. If you have no way to get a reference to it inside of this blueprint, your best bet would be to set up something like so:

This will only work correctly if only one of them exists in your level, since this will end up getting all of them. Otherwise you’ll need to store the reference in a variable when you spawn it to use it later. If it is always in the level and never actually gets spawned, you could set the reference before you even start as well and use that.

Ok so first of all i got it working.
i tried what you did and it said warning for some reason as i will show you in this screenshot

So I felt kinda bad because i dont want to bother you so much XD

So i was experimenting with the blueprint and it seems i got it working! i had to connect set hidden in game target to the return value on the spawn actor from class. I was actually quite surprised i got it working so randomly haha.
thank you for your help this is the second time you helped me im grateful