Hello
I am trying to set the material of one unit, to the same material as another unit. How do I achieve this?
The way I set the material of the unit is the following, in my c code:
void *materials[] = { _resource_api->get("material", lua_material_string) }; mesh_api->set_materials(o.mesh, 1, materials);
where lua_material_string is 'content/materials/yellow'
What I want is therefore to get a string similar to this, from another unit. I've tried the following, in c and lua:
c:
uint32_t mesh_name = _unit->mesh_name(lua_unit_base, 0); uint32_t mesh_handle = _mesh_api->lookup(lua_unit_base, mesh_name); void *mat = _mesh_api->material(mesh_handle, 0); void *materials[] = { mat }; _mesh_api->set_materials(o.mesh, 1, materials);
lua:
stingray.IdString32.to_string(stingray.Mesh.material_slot_name(stingray.Unit.mesh(unit, 1), 1))
stingray.Unit.get_property(unit, "materials")
None of which seems to give me what I want.
Is there a way to retrieve the material of a unit/mesh in the form 'content/materials/yellow'? Alternatively, is there another way of setting the material of one unit to the same material as another unit?
Thanks for the help!
This thread deals with material strings in LUA:
What is the function you are calling returning? Is it a hex string? Stingray manages material paths internally not as strings but as hashes for efficiency.
Can't find what you're looking for? Ask the community or share your knowledge.