so basically I have an array of objects though right now I only have one array element basically I want to effect the alpha level of that script from another script… i am able to access the boolean of said array element from the other script but the alpha levels doesnt seem to want to change …in desperate need of assistance
here is the script that is changing the booleans of the script that is attached to the array element
script A:
public List<float> angles; // Set the angles in the editor, like 0, 45 and 90.
public int currentAngle = 0; // Index of the current angle.
public GameObject[] shadowObjects;
// private alpha_test alphascript;
/*private float alpha1 = 1.0f;
private float alpha2 = 0.5f;
private float alpha3 = 0.0f;*/
// Use this for initialization
void Start () {
//shadowObjects = new GameObject[1];
//shadowObjects[0].GetComponent<alphalevel>(). AlphaLevelisone = false;
}
// Update is called once per frame
void Update () {
/////////////////////////////////sprite opacity////////////////////////////////////////////////////////////////////
//1 -45 2 = 45 3 = 90 4 = 124
//transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.Euler(0.0f, 0.0f, angles[currentAngle]), 45.0f * Time.deltaTime); // 45 = 45 degrees a second,
transform.rotation = Quaternion.Euler(0.0f, 0.0f, angles[currentAngle]);
if(currentAngle == 2 ) //if currentangle is ends up adding up to total number of lists then it will rest back to the original position
{
//shadowob[1].alphascript.AlphaLevelisone = true;
shadowisoN();
}
if(currentAngle != 2 ) //if currentangle is ends up adding up to total number of lists then it will rest back to the original position
{
//shadowob[1].alphascript.AlphaLevelisone = true;
shadowisoff();
}
}
//turns alpha level to 1
void shadowisoN()
{
shadowObjects[0].GetComponent<alphalevel>(). AlphaLevelisone = true;
//turns shadowisoff alpha level to o
}
void shadowisoff()
{
shadowObjects[0].GetComponent<alphalevel>(). AlphaLevelisone = false;
}
script B : is the script that is attached to the array gameobject. im trying to access the alpha level of this gameobject via script from script A
public class alphalevel : MonoBehaviour {
public bool AlphaLevelisone = true;
public float fullalpha = 1.0f
public float noalpha = 0.0f
//private Animator animator;
void Awake ()
{
}
// Use this for initialization
void Start () {
//animator = GetComponent<Animator>();
AlphaLevelisone = false;
}
// Update is called once per frame
void Update () {
SpriteRenderer spRend = GetComponent<SpriteRenderer>();
Color col = spRend.color;
spRend.color = col;
if(AlphaLevelisone == true)
{
spRend.color = col;
Color col = spRend.color;
col.a =fullalpha ;
print("it is true");
}
else if(AlphaLevelisone == false)
{
spRend.color = col;
Color col = spRend.color;
col.a = noalpha;
print("it is false");
}
}
the booleans seem to work its just the alpha level that isnt working
Thoughts also please keep any sample code in c# also try an keep things as simple as possible
im not a technical coder yet thnx