Making new material vs setColor

Hello, I am just starting and have following issue with 8th step (https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_picking): 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,

“Common/MatDefs/Misc/Unshaded.j3md”);

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

results.getCollision(i).getGeometry().setMaterial(newmat);





Why first option fail? Thanks in advance.



PS. My first post, so welcome everybody!

The problem is that you’v hit an object that does not have the material unshaded.j3md

if it, for instance, uses Lighting.j3md then the color varible name is “color_map” or something like that.

To check what attribute the color is you can find it herE:

http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/core-data/Common/MatDefs/?r=5958#MatDefs%2FMisc

find your material in the sub folders, then open the j3md file and see for varibles of the class Color. The name of those variables are the name to use when setting color to that material.

Do not double-post!

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/making-new-material-vs-setcolor-1/