Making new material vs setColor

Hello, I am just starting and have following issue with 8th step ( I am trying to change color of cube which was hit. Unfortunately, that


results.getCollision(i).getGeometry().getMaterial().setColor(“Color”, ColorRGBA.Gray);


cause “java.lang.IllegalArgumentException: Material parameter is not defined: Color”.

When I make new Material, everything seems to be fine:


Material newmat = new Material(assetManager,


newmat.setColor(“Color”, ColorRGBA.Gray);



Why first option fail? Thanks in advance.

PS. My first post, so welcome everybody!

It is possible that you are picking something else, and that thing does not have the Unshaded material.

What you can do to test is to get the name of the geometry you picked, and the name of the material:





Then confirm they are what you expected.

You can also print out all of the material parameters when you hit it with:




Remember that getCollision(i) is not necessarily the closest geometry. You want to use:




1 Like

Thanks for help Sploreg. It seems problem was trying change color of golem (my ray often crossed his body, after cube) and as I suppose there is no color into golem material.

Using [java]getClosestCollision()[/java] eliminate problem completly - unless I aim on golem of course.

The golem is probably using the lighting material.

Look for Lighting.j3md. That is a material definition file that shows you what parameters it accepts.