How to set visibility of particle system?

Hi all,

So I’m having an issue getting the visibility of my particle system to change. I’m trying to create an effect of fireflies that show up at night in front of the player’s camera. I created the particle system and added it to the Player Pawn blueprint. In the event graph, I cast to the skydome blueprint and get the bool “IsItNightTime?” that I set there. Create a branch for if yes, turn particles on, if no, turn them off. For some reason though the visibility of the particles never changes. I know my bool works because its also driving music for day time and night time and this is changing as it should.

I’ve tried starting the particles with visibility off and on and I’ve also tried creating this setup inside the skydome and casting to the player pawn. Nothing works. They’re either always on or always off depending on the visibility I set in the components tab. Any ideas?

Thanks!

I’ve also tried using Activate and Deactivate for the particle system. This does not work either.

It looks like you aren’t actually casting anything. You’ll need to get the skybox object from the level. You could do that with an exposed object variable, maybe? If I’m reading the blueprint wrong and there actually is something selected in there, try a print string off the cast failed node to see of the cast is actually going through, I suspect it isn’t.

Thank you Renkin. I’m obviously very new to BP in general.
So I don’t really know what Casting does. I thought it just meant you’re grabbing a reference to another blueprint and then calling a function inside that BP.

So I found this video:


So I created a variable for the skydomeBP and then referenced the IsItNightTime? bool from there. Then I added a string to the end of each of the visibility toggles so I could see if they were working properly. Then I added an IsValid node to the reference to my skydome to make sure its working and it says its invalid. I don’t understand why though.

Apologies for the delay. First of all, casting doesn’t get things. It takes an object you’ve already gotten and attempts to read it as a different type of object. For example, what if we want to get a variable from MyCharacter somewhere else? We would use a “get player character” node. But that only gives us a reference to Character, not MyCharacter. To deal with this, we cast the character to MyCharacter, and from there we can get all the specific MyCharacter stuff, like variables and custom events.

Now the tricky part of what you are trying to do here is that you can’t reference level objects from a blueprint without actually placing it in the level. However, due to the way the player start is set up, you can’t really set any exposed variables from there the way they show in the video. My solution would be to use a “Get All Actors of Class” node and set the class to your skysphere. Drag off of the out array and use a “Get” node. Leave the index at 0, there shouldn’t be more than one anyway. You should be able to drag off that and get your boolean. Sorry if that isn’t exactly the most intuitive answer, but I hope it helps.

No that actually totally makes sense. I did more tutorials while I was waiting for a reply and found out that casting wasn’t what I wanted and also figured out the reason I was having problems was because I wasn’t grabbing the BPskydome that was in the level. Your description (now that I can understand it better) helps a lot. I’m also looking around for someone locally that can help tutor me in blueprint :slight_smile:

Thanks a lot Renkin!