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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Question]Edit Material Parameters C++

I have an object that I would like to make blink on and off, I was able to get it to work in Blueprint just fine. But when trying to do the same with C++ it builds with no errors but when tested in the editor it crashes with no error message. I have gone through my code and found out I am crashing anytime I try to get the material of the static mesh itself. My Code is very simple right now, but I can’t seem to figure out what I am doing wrong.

.h

 UMaterialInstanceDynamic* MILight;



Inside of my function I am running this code.

 UMaterialInstanceDynamic* MILight = UMaterialInstanceDynamic::Create(Lamp->GetMaterial(0),this); // This is where I appear to be crashing at.

 MILight->SetVectorParameterValue(FName(TEXT("LightColor")),FLinearColor(0.0,0.0,0.0,1.0);
 
 Lamp->SetMaterial(0, MILight);

Any help would be greatly appreciated!

Product Version: Not Selected
Tags:
more ▼

asked Mar 11 '14 at 02:40 AM in C++ Programming

avatar image

ue4-archive ♦♦ STAFF
49.9k 3666 1995 9121

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Dear Tyler,

Please post your code where you are setting Lamp pointer properly.

Most likely your Lamp is not valid reference

to test this, modify your code as follows, probably you will not get a crash but still nothing will happen, because you are not setting the Lamp reference properly.

 if(!Lamp) return;
 //~~~~~~~~~~~~
 
 UMaterialInstanceDynamic* MILight = UMaterialInstanceDynamic::Create(Lamp->GetMaterial(0),this); // This is where I appear to be crashing at.
  
 MILight->SetVectorParameterValue(FName(TEXT("LightColor")),FLinearColor(0.0,0.0,0.0,1.0);
  
 Lamp->SetMaterial(0, MILight);
more ▼

answered Mar 11 '14 at 02:40 AM

avatar image

ue4-archive ♦♦ STAFF
49.9k 3666 1995 9121

avatar image ue4-archive ♦♦ STAFF Mar 11 '14 at 02:40 AM

Okay, the pointer is where I went wrong. It is all working now, was a small mistake on my end. Thank you!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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