I am making a system where you can hit objects in my game, and I want particles to fly off the object after they hit it to indicate that it’s being hit. The particle colors should match the object colors for it to look nice.
It works flawlessly except for one issue: Right now, it ray casts to the part they’ve clicked on, gets the color, and sets the particle color to that part’s color and it’s good.
But, when a player clicks on a Mesh or MeshPart, the whole technique goes out the window; the underlying part can be a totally different color than the mesh.
I’m thinking the only way to resolve this would be to somehow get the actual pixel color that the user has their mouse over. Is there a way to do this in ROBLOX?
Unfortunately, I do not think there may be a way to read pixels yet. It would be very useful. But that would form an amazing #platform-feedback:engine-features post!
As TheCarbyneUniverse said, you cannot get pixel colors from what the player hits. You could possibly set the particle texture to the mesh’s texture. Although, depending on the texture, this doesn’t always look good.
Another alternative is manually specifying colors for objects in your game. That way if you hit a mesh, you can manually specify a color (or colors) for the particles.