xtr33me
03-17-2011, 07:14 PM
Unsure if there is maybe something that I am jsut missing here. I currently have the below config and when I destroy a block I want to simply set a random material from my array to the blocks. What is happening is sometimes the material is not showing. I see that the wireframe block is there but there is no material showing, it just looks invisible. Am I applying this incorrectly? Is there something I can test to see if the call loaded the material correctly? Now it seems every time I start the game, which is using the PreBeginPlay method, all the blocks seem to have a meterial. It seems to only be when I call SetRandomColor elsewhere that it intermittantly will set a block to no color. I was also logging out the index at one point, but the indexes were always valid and it wasn't always with the same color index.
var MaterialInstanceConstant myMatInst;
simulated function PreBeginPlay()
{
MyBlockMats[0] = Material'CubeFectionPackage.Mats.Mat_Blue';
MyBlockMats[1] = Material'CubeFectionPackage.Mats.Mat_Green';
MyBlockMats[2] = Material'CubeFectionPackage.Mats.Mat_Grey';
MyBlockMats[3] = Material'CubeFectionPackage.Mats.Mat_Orange';
MyBlockMats[4] = Material'CubeFectionPackage.Mats.Mat_Purple';
MyBlockMats[5] = Material'CubeFectionPackage.Mats.Mat_Red';
MyBlockMats[6] = Material'CubeFectionPackage.Mats.Mat_Yellow';
}
simulated function PostBeginPlay()
{
myMatInst= new(self) class'MaterialInstanceConstant';
self.SetRandomcolor();
}
function SetRandomcolor()
{
if(myMatInst != none)
{
myMatInst.SetParent(MyBlockMats[Rand(7)]);
StaticMeshBlock.SetMaterial(0,myMatInst);
}
}
var MaterialInstanceConstant myMatInst;
simulated function PreBeginPlay()
{
MyBlockMats[0] = Material'CubeFectionPackage.Mats.Mat_Blue';
MyBlockMats[1] = Material'CubeFectionPackage.Mats.Mat_Green';
MyBlockMats[2] = Material'CubeFectionPackage.Mats.Mat_Grey';
MyBlockMats[3] = Material'CubeFectionPackage.Mats.Mat_Orange';
MyBlockMats[4] = Material'CubeFectionPackage.Mats.Mat_Purple';
MyBlockMats[5] = Material'CubeFectionPackage.Mats.Mat_Red';
MyBlockMats[6] = Material'CubeFectionPackage.Mats.Mat_Yellow';
}
simulated function PostBeginPlay()
{
myMatInst= new(self) class'MaterialInstanceConstant';
self.SetRandomcolor();
}
function SetRandomcolor()
{
if(myMatInst != none)
{
myMatInst.SetParent(MyBlockMats[Rand(7)]);
StaticMeshBlock.SetMaterial(0,myMatInst);
}
}