So basically, I’m working on this pong game (yup still finishing it up) and after fixing a bug with the animation player node changing the position of the power orb to its local position, I was going to add this particle effect for this power orb when it was collected. I’ve made the particle effect and added everything I needed for it (like the scale and color curves) but now I want to know how I can access those values and change with the code so that the particle has a different effect based which orb it is. I could change the modulate and self-modulate values, but they don’t get me the color that I actually want for it.
Does anyone have any ideas on what I could do to get these values, or a completely different work around to this?
self modulate won’t modulate GPUParticles2D from what i knew. you will need to access the process_material to then access the color
so to change the color from a GPUParticles2D node is like this:
So I tried out the code and tbh I never knew this process material actually had a color variable + never even seen this dropbox color picker style. It works and is kind of fine, but I’m just wondering if there’s still a way for me to actually edit the particle process material for each orb cuz I may wanna tweak the color a little bit
to how I want it.
The only solution I’m thinking of rn is if I just make 5 different particle nodes for each orb which would be a last resort cuz I wanna be sure if there isn’t a better way of doing this.
You can create 5 color variables with @export annotations for each of the orbs, adjust it in the editor to how you want it exactly, then assign the color to the particle during runtime depending on the orb it hit.
@export var color1: Color
@export var color2: Color
@export var color3: Color
@export var color4: Color
@export var color5: Color
Or better yet, you can create a custom class for your orb, assign a color variable to it, then when your balls hits this orb, read that value off the orb’s node. This way your main code will stay the same and you can add as many colored orbs as you want.
I’m kinda having a hard time understanding that tho. Could you maybe show me in action how this would work?
Edit: I’m starting to think maybe just changing the overall color won’t do justice, so I might as well just make 5 separate GPUParticles2D nodes for each orb color, or is it possible to store more than one process_material in one Particle node and switch between them?
You can make a custom property on your particle node @export var process_materials: Array[ParticleProcessMaterial]
And create multiple materials there, and then switch them in runtime with code.
I might not be able to access PC for the next couple of days, but I will try to create you some example when I can