Concept is simple, character turns around based on which side of the screen the mouse is on. The script is:
void Update () {
var MousePosition = Input.mousePosition;
var PlayerPosition = Camera.main.WorldToScreenPoint(transform.position);
if (MousePosition.x < PlayerPosition.x)
{
SpriteRenderer.flipX = true;
}
if (MousePosition.x > PlayerPosition.x)
{
SpriteRenderer.flipX = false;
}
}
I’m getting the error “CS0120: An object reference is required to access non-static member 'UnityEngine.SpriteRender.flipX”
I don’t know exactly what I’ve done wrong. If sprite render flip is a static variable, how would I edit it? Or is something else a static variable? I’m not sure really, var is still somewhat confusing to me.
Thanks for any help!