Hi, I’m new to Unity and Javascript and I’m having a bit of trouble working out a few things with changing a materials on a plane upon a keydown event.
For instance, when I want the material on the plane I’m using for my character to change to a picture I’ve created of my main character facing left. I’ve had a look though various other questions similar to my own and I’m just not sure.
I’m not sure if this code is correct at all;
function Update () {
if (Input.GetKeyDown("a")) {
body.renderer.materials = MaterialLeft;
}
}
I’m curious as to where I would put the image called “MaterialLeft”, do Ineed to create a new material, located where I keep my assets, or will this be made on the fly using the code. And also, whether that code would work.
Any response will help!
Thanks in advance.
Works wonderfully well. Thank you, I'm really grateful.
– Caramelkisses