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"

Change textures when press key 1 2 or 3?

So I have an instanced material where the base colour texture is with a parameter 2D.

The intention is to be able to press 1 2 or 3 and then this switches the texture to a different texture named 1, 2 or 3.

I've got this far with my blueprint, but I don't know how to change the "Set texture Parameter" Value node to the different textures based on what key I've pressed?

Any pointers? alt text

Product Version: UE 4.18
Tags:
more ▼

asked Feb 20 '18 at 04:41 PM in Blueprint Scripting

avatar image

dedvendies
1 1

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

1 answer: sort voted first

As long as the material you are trying to change has the parameter 'switcher', then you will want to set the texture on each key press, instead of the 'Begin Play'.

There is a 'Value' node on the Set Texture function, clicking this drop down will show a list of textures you have available to use.

more ▼

answered Feb 20 '18 at 05:08 PM

avatar image

Dune
1.8k 52 36 200

avatar image dedvendies Feb 20 '18 at 05:48 PM

alt text

avatar image dedvendies Feb 20 '18 at 05:48 PM

You mean like this?

avatar image dedvendies Feb 20 '18 at 05:50 PM

Is there a more elegant way to do this if I scaled it up?

Ie I have textures called 01.png, 02.png, 03.png...50.png, show the texture whose name corresponds to the number keys pressed? Could I do it with an array of textures or something? I guess how do I convert a number input into a texture named as a number?

avatar image Dune Feb 20 '18 at 06:25 PM

For input you will have to create some method to read each keys and store them in a variable. But for the multiple amount of textures, look at using a map with the key as an integer and the value as a texture.

That way, you can have as many textures linked to a number as you want. Then when you want a texture, use the map with the key to find your given texture.

avatar image dedvendies Feb 20 '18 at 06:31 PM

" key as an integer and the value as a texture."

This is the bit I'm struggling with. Could you post a blueprint example of how to take an integer value and convert it to a texture name of that same integer?

I don't know what nodes to go about dealing with this.

Thanks for all the help! Really appreciate it.

(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