0
Answered

Change Material

Rodrigo Machado 6 months ago in Game Creator updated by Marti (Lead Developer) 6 months ago 4

Hi,

I want to activate a stealth mode when entering bushes. For that I would like to know how to make the character transparent. I thought about doing it by changing the alpha of the material, or changing the material itself. But the "change material" feature does not make the switch. How could I perform this action?

Unity version:
Unity 2019.2.0f1
Game Creator version:
1.1.5

Answer

Answer

Ok, the easy way to do this without using explicit shaders is to make a new transparent material from the body and the joints and swap them out when entering a trigger area.

  1. Go into your player in the hierarchy and drill down to body and joints.
  2. Click on body and look in the inspector you will see a field called material and a body material is there. Select that and it will highlight that material in your project.
  3. Now duplicate this material control+d and rename it Body2
  4. Do the same for the joints and rename that joints2
  5. Click on your body2 material and change the renderer mode to transparent.do the same for joints2 material
  6. To be able to see what degree of transparency you want drag this new material onto your player body and also for the joints
  7. Now when you select the body2 material in on the player click the color and change the transparency at the bottom, even the color if you want. Do the for joints too.
  8. Now when you are done drag back the original body and joints material to your player.
  9. Let us test this now
  10. Make a trigger on start
  11. Make a wait action for 5 seconds
  12. Make an action change material and drag your body2 material into that select gameObject and drag the body gameObject of your player to that. Do not select player rather Gameobject.
  13. Make another action change Material and do the same for your joints.
  14. Hit play and after 5 seconds it will change
  15. You can then do the opposite to reset your original materials.
  16. So now you could make a trigger area like your bushes and when the player walks into that area you just swap the material as above.
GOOD, I'M SATISFIED

Worked perfectly!

What I didn't understand was that I needed to put the component with the material (body or joint) and not the player. I ended up also understanding the "material index" function as I read about it here on the forum.

Thank you very much again for your support!

Satisfaction mark by Rodrigo Machado 6 months ago
+1
  1. Use an action enable component (on/off)Under Player/Character/ Armature turn off the skinned mesh renderer on body and joints
  2. Or use action set active (on/off)Character und the player

But I just saw that the action Set active is not working, so I will report a bug.

Thank you for your attention. This method should really work, I hadn't thought about that alternative. But I would like to leave the character still visible, only with transparency. Sort of like League of Legend.

Answer

Ok, the easy way to do this without using explicit shaders is to make a new transparent material from the body and the joints and swap them out when entering a trigger area.

  1. Go into your player in the hierarchy and drill down to body and joints.
  2. Click on body and look in the inspector you will see a field called material and a body material is there. Select that and it will highlight that material in your project.
  3. Now duplicate this material control+d and rename it Body2
  4. Do the same for the joints and rename that joints2
  5. Click on your body2 material and change the renderer mode to transparent.do the same for joints2 material
  6. To be able to see what degree of transparency you want drag this new material onto your player body and also for the joints
  7. Now when you select the body2 material in on the player click the color and change the transparency at the bottom, even the color if you want. Do the for joints too.
  8. Now when you are done drag back the original body and joints material to your player.
  9. Let us test this now
  10. Make a trigger on start
  11. Make a wait action for 5 seconds
  12. Make an action change material and drag your body2 material into that select gameObject and drag the body gameObject of your player to that. Do not select player rather Gameobject.
  13. Make another action change Material and do the same for your joints.
  14. Hit play and after 5 seconds it will change
  15. You can then do the opposite to reset your original materials.
  16. So now you could make a trigger area like your bushes and when the player walks into that area you just swap the material as above.
Answered

Perfect answer. Thanks EagleEyez