link textHi.
I had lots of trouble trying to swap a material on a mesh. It requires more fussiness than UE3.
This is what is required:
Convert the StaticMesh to Interpactor (select in browser first, then use Replace…)
Set up a TriggerBox or whatnot to fire the action. A BeginOverlap event with the trigger will need to compare if its overlapping actor is the PlayerPawn.
Add as a variable the actor whose mesh component you want to change in the eventgraph.
The Trick
Drag off the Interpactor variable’s blue output and choose Variables > DynamicSMActor > Get Static Mesh Component.
This lets you assign the mesh as a target for the Set Material (Target is Primitive Component) action.
NB: There are Set Material actions for other categories, like particles and blurs.
An example, Mesh_ChangeMaterial.umap, which uses comparison of mesh and comparison of current material is provided.
link text
This should totally work (and be easy to set up) in the Level Blueprint!
We have made some changes to this since the beta you have, but in today’s code you can select the InterpActor in the level, right click in the Level Blueprint and choose ‘CallFunction on MyMesh’ → ‘Mesh’ → ‘Set Material’ and it adds the reference node to the mesh actor, and the function node. No more digging around for the component. You can also place a ref to the mesh, drag off and choose that function that way.
Hey Tom,
I’m unable to open the example you provided as it can’t find the content you used. It sounds though like you might be using a level trigger volume and level blueprint. While this is not a bad idea it may be easier to try it as its own blueprint. I imagine this is similar to what you did. Simply add your mesh in the components along with a Box Component. The idea here is that the box component acts as a trigger volume for you. Make sure to give them variable names.
Then in the scripts eventgraph just use a RecieveActorBeginOverlap and RecieveActorEndOverlap to control the material change. Use a get on the static mesh variable and use Set Material to set its material then link them up as below.
In this example it will change to the BasicAsset03 (Green) when you enter the volume and back to BasicAsset01 (Red) when you leave the volume.
Let me know if you have any questions about this.
Hi Ryan, thanks for the informative answer.
You are right - I set up in the scene EventGraph, not a new blueprint.
I attached the working method I used as a pic. I don’t know why the .umap didn’t open, as it used default assets.
I will check out more your example. Thanks!