Forum

Change material on click in object?.

29 April 2016 15:23 #9146
Hello. How can change material on click in object?. Thanks.
29 April 2016 15:34 #9148
Change material on click in object?.
You can do this in two ways:
1. with the logic editor
example, blend file

2. via API
code snippet
Development Lead | Twitter
03 May 2016 13:01 #9200

Reply to post of user Yuri Kovelenov
You can do this in two ways:
1. with the logic editor
example, blend file

2. via API
code snippet


Thanks.
14 September 2016 15:41 #11793
my object name: mamparaOb
my material name: mamparaLight

var lightObMampara = m_scenes.get_object_by_name('mamparaOb');

// console.log(m_material.get_materials_names(lightObMampara));
// console.log(lightObMampara);

m_material.set_emit_factor(lightObMampara, "mamparaLight", 1);
m_material.set_diffuse_intensity(lightObMampara, 'mamparaLight', 1);


this dont work for me in b4w 16.8.0, i get this error:

B4W ERROR: Couldn't set property "emit_factor"!error @ print.js:73exports.set_emit_factor @ material.js:343main_canvas_click @ casaGasNatural.js:135
print.js:73 B4W ERROR: Couldn't set property "diffuse_color"!


This:
console.log(m_material.get_materials_names(lightObMampara));
return an empty array [ ] but my object have assigned one material named mamparaLight.
15 September 2016 14:48 #11817
Hi,

Could you please export your project with the Project Manager and attach here the archive?
Development Lead | Twitter
19 September 2016 12:27 #11892
Force Dynamic object checked?

Next time you can say hello, always a good way to start :)
19 September 2016 22:32 #11919
Reply to post of user martial
Next time you can say hello, always a good way to start :)

It's true, you're right, sorry, I had a bit rushed and passed me.


Reply to post of user martial
Force Dynamic object checked?

Tomorrow I will try to see that this, thank you.
 
Please register or log in to leave a reply.