Question by
beyondeffects · Nov 06, 2015 at 06:28 AM ·
c#script.scripting beginner
trying to fade alpha based on the Y angle using a range so every 90 degrees the material changes but fades back n forth
void Update() {
if(Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
if(Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
if ((gameObject.transform.rotation.eulerAngles.y) < 90)
{
blendOne += blendSpeed;
rend.material = Mat1;
}
else {
rend.material = Mat2;
}
blendOne += blendSpeed;
if (blendOne > 360.0f)blendOne = 0;
}
}
Comment
The first part
if angle < (Range (0, 90)), (Range (181, 270){ do this rend.material = $$anonymous$$at1; }
i came up with this formula for what i want for alpha blending x = ( gameObject.transform.rotation.eulerAngles.y ) if angle = 45 + x { rend.material = $$anonymous$$at1.color.a < 50f; rend.material = $$anonymous$$at2.color.a < 50f; }
so no matter on what angle it is the halfway at 45 always fades the alpha trying to implement that using the docs not really finding what i need.
I think i need to have all the equation altogether to make it work but the syntax im missing just cant get it to work the way I'm hoping to. Any help is muchly appreciated