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"

How to change enemy colour based on level?

Is it possible to change the colour of an enemy AI based on the level?

Product Version: UE 4.16
more ▼

asked Aug 02 '17 at 02:11 AM in Blueprint Scripting

avatar image

43 26 31 38

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

1 answer: sort voted first

Inside the material of the Enemy AI, create a vector parameter, make sure you name it like "AIColor", (this is important because you'll need to use this later) and multiply the white pin from this node by whatever is goes into the final 'Base Color' of the material.

alt text

Then inside the AI, on BeginPlay, get the AI's mesh, Create Dynamic Material Instance and add the AI's mesh to the Target, Element Index is what material you're going to change. If he only has 1 material, keep the index at 0. Get the AI Mesh and Get Material and plug that into Source Material. Drag off from Return Value and Set Vector Parameter Value. Change the Parameter Name to AIColor , or whatever you called the Vector Parameter in the Material.

Next create a new variable and change the Variable Type to Linear Color and add elements to this array in the Details panel, changing the colors to whatever you want. Make this variable an array, drag it into the blueprint it and get it, drag off from it and search 'Get'.

alt text

You'll need to have some sort of level counter that plugs into the Integer pin in the 'Get' node to change the color each level. Changing this 0 manually to a different index should now result in your AI changing color.

Let me know if this helps! :)

material.png (101.7 kB)
bp.png (96.5 kB)
more ▼

answered Aug 02 '17 at 03:03 AM

avatar image

6 1 4

(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