SetScalarParameterValue Access Violation

When you delete the line, does it work as expected, as in the material changes, or does it just not crash? If it just doesn’t crash you’ve found the offending line of code, and now we can work toward fixing it :slight_smile:

I’ve looked a bit into “EXCEPTION_ACCESS_VIOLATION reading address 0xffffffff”. In Unreal it tends to happen when something is not (yet) set or initialized. So this might be an issue of you not calling Super methods on your overridden methods(for example: in your class derived from UStaticMeshComponent). It could be that you’re trying to change parameters of a material that is not yet initialized, used etc. Maybe you’re overriding the materials in blueprints or something like that, and the material you’re trying to change in C++ does not have the parameter.

Also, since I don’t have the whole code, are you saving a reference to your material to materialDynamic variable? You can access it in a UStaticMesh derived class via GetMaterial

UMaterialInstanceDynamic* Mat_Inst = this->GetMaterial(0);
if(Mat_Inst)
{
    Mat_Inst->SetScalarParameterValue(FName("Hover"), 1.0f);
}

Assuming that this is the only material used on the mesh.

P.S. Make sure your parameter is “Hover” and not "Hover " with a trailing space.