Jump to content

[SOLVED] fractured object material not filling in after shattering C#


photo

Recommended Posts

I have been able to fracture a mesh, but when it fractures it is not applying a material to the new surfaces within the fractured mesh.

I saw elsewhere on the forum the use of [   bf.SetMaterial(shatteredMaterial.Name);  ]  but when I attempt to use this Unigine reports that bodyfracture does not contain a definition for SetMaterial

Anyone have insight into where I am going wrong anyone able to provide a functional example?

Here is the code I am using (C#):

	[ShowInEditor][Parameter(Tooltip = "Object for shattering")]
    private ObjectMeshDynamic mesh = null;

    [ShowInEditor][Parameter(Tooltip = "Shattered object Material")]
    private Material shatteredMaterial = null;

	private BodyFracture bf;


	private void Init()
	{
		Node n = World.GetNodeByName("ObjectMeshDynamic_2");
		ObjectMeshDynamic mesh = n as ObjectMeshDynamic;
		BodyFracture bf =new BodyFracture(mesh);
		bf.Threshold = 0.05f;
		bf.Mass = 5f;
		bf.CreateShatterPieces(10);
		bf.Broken = true;
		bf.Material  = shatteredMaterial.Name;
	}
...

 

Untitled-1.jpg

Link to comment
  • silent changed the title to [SOLVED] fractured object material not filling in after shattering C#
×
×
  • Create New...