Error CS0176 on Renderer
i wanna make that a Character have diferent Jump based on it color but when i try to access a public Static variable throw me the error C0176 somebody know how Fix it?
Color Switch Script:
public class Player_Switch : MonoBehaviour
{
public static Color color1;
public static Color color2;
public Color color_1;
public Color color_2;
public static Renderer ActualColor;
void Start ()
{
color1 = color_1;
color2 = color_2;
ActualColor = gameObject.GetComponent<Renderer>();
ActualColor.material.shader = Shader.Find ("Standard");
ActualColor.material.color = color1;
}
// Update is called once per frame
void Update ()
{
Character_Switch ();
}
void Character_Switch()
{
if (Input.GetButtonDown("Switch"))
{
if (ActualColor.material.color == color1)
{
ActualColor.material.color = color2;
}
else if (ActualColor.material.color == color2)
{
ActualColor.material.color = color1;
}
}
}
}
this is from the Script that try to access "public static Renderer ActualColor" but throw me the C0176
void Update()
{
if (Switch.ActualColor.material.color == Switch.color_1)
{
RojJump(); //Salto de Roja
}
else if (Switch.ActualColor.material.color == Switch.color_2)
{
EstJump(); //Slato de Estaño
}
}
Comment
Best Answer
Answer by Toon_Werawat · Apr 18, 2016 at 07:50 PM
I'm assume at other script you said it error have this line of code
public Player_Switch Switch;
If you have. All you have to fix is. Change from
if (Switch.ActualColor.material.color == Switch.color1)
To this
if (Player_Switch.ActualColor.material.color == Player_Switch.color1)
Because "ActualColor" is a static. Which can't access from instance.