Really simple animation/movement question

Hello my names Chris ,

I’ve just started using unity and I’m currently creating a 2d platformer, I’m stuck on something I feel there’s an extremely simple answer but it’s just not working for me. Upon clicking the d key I would like to load up the material for the character movement animation and for it to return to the original stationary material upon releasing from the d key. What is the goddamn code for this?

Provided that you’ve created and setup two materials in the editor you can use public variables in your MonoBehavior to refer to these materials and then just assign them to your gameObject given the conditions you’ve outlined:

if (Input.GetKeyDown(KeyCode.D)) { 
  gameObject.renderer.material = my_running_material;
} else if (Input.GetKeyUp(KeyCode)) {
  gameObject.renderer.material = my_standing_material;
}

This is not a code snippet you should use verbatim. It’s just to illustrate the basic approach.