x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Instanced Static Meshes render with default material

Hey I have a problem with InstancedStaticMesh, the mesh instances are rendered with default material and I can't figure out why

what I did is:

opened a new c++ project just basic code, I've created:

c++ Actor class "Tile", declared UStaticMesh in it, I've created A blueprint from this class and set the static mesh and material, the material is created by me and it has the "Used with Instanced Static Meshes" flag set

c++ Actor class "MyLevel", declared UInstancedStaticMeshComponent, and a TSubclassOf in it, the "TSubclassOf" member is UPROPERTY that can be edited anywhere and it is set to Tile Blueprint that I've created.

In "MyLevel"constructor I create instancedStaticMeshComponent, in BeginPlay() I check if TSubclassOf is set and if I set the InstancedStaticMesh->SetStaticMesh() and just to test I also add instance of that mesh, and now the mesh is rendered but with default material and I have no idea why. Can any one help solving this problem ?

code from MyLevel class

.h File https://onedrive.live.com/redir?resid=89D22DBC98E39077!1185&authkey=!ANZi0PuM4tVWxPE&v=3&ithint=photo%2cpng

.cpp file https://onedrive.live.com/redir?resid=89D22DBC98E39077!1187&authkey=!ADpm_i-3qAiKzVE&v=3&ithint=photo%2cpng

code from Tile class

.h file https://onedrive.live.com/redir?resid=89D22DBC98E39077!1184&authkey=!ANvirlzNzWTTlNU&v=3&ithint=photo%2cpng

.cpp file https://onedrive.live.com/redir?resid=89D22DBC98E39077!1183&authkey=!AF5y5dopCN1oUKk&v=3&ithint=photo%2cpng

Material https://onedrive.live.com/redir?resid=89D22DBC98E39077!1188&authkey=!AAVk9YwjENxlAr8&v=3&ithint=photo%2cpng

tile blueprint https://onedrive.live.com/redir?resid=89D22DBC98E39077!1186&authkey=!AK--0v9Cmwn3TC8&v=3&ithint=photo%2cpng

MyLevel class Settings in Editor https://onedrive.live.com/redir?resid=89D22DBC98E39077!1190&authkey=!ADm8M5Fi8XWCdBg&v=3&ithint=photo%2cpng

and the result on left instanced static mesh with Tile_BP blueprint, on right Tile_BP blueprint dragged and dropped in editor https://onedrive.live.com/redir?resid=89D22DBC98E39077!1189&authkey=!ADUj0WUnAZ328qM&v=3&ithint=photo%2cpng

Can any one tell me why this is happening ?

Product Version: Not Selected
Tags:
mylevel_h.png (188.9 kB)
mylevel_cpp.png (204.3 kB)
mylevel_h.png (188.9 kB)
mylevel_cpp.png (204.3 kB)
tile_h.png (198.1 kB)
more ▼

asked Jun 02 '16 at 08:16 PM in C++ Programming

avatar image

Mlody "Swidwin"
327 12 11 25

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I've sorted the problem by adding a UMaterialInterface into my Tile class and loading my material in construction script than when I call AddInstance on InstancedStaticMeshComponent and get its index I call SetMaterial() passing in the instance index and the appropriate material

Update: Right now I only have a StaticMeshComponent in my tile class I have made a blueprint from it I set things as shown on pictures in my question but I call SetMaterial() on instancedMeshComponent passing in instance index and material of appropriate index that I get from tile class StaticMeshComponent

more ▼

answered Jun 03 '16 at 12:36 AM

avatar image

Mlody "Swidwin"
327 12 11 25

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question