bool isMoving;
Vector3 characterScale;
float characterScaleX;
// Start is called before the first frame update
void Start()
{
isMoving = true;
characterScale = transform.localScale;
characterScaleX = characterScale.x;
}
// Update is called once per frame
void Update()
{
if (transform.localPosition.x < waypoints[index].position.x && isMoving == true)
{
myAnimator.SetBool("Walking", true);
transform.position = Vector2.MoveTowards(transform.position,
waypoints[index].position,
moveSpeed * Time.deltaTime);
}
else if (transform.localPosition.x > waypoints[index].position.x && isMoving == true)
{
characterScaleX = -characterScaleX;
myAnimator.SetBool("Walking", true);
transform.position = Vector2.MoveTowards(transform.position,
waypoints[index].position,
moveSpeed * Time.deltaTime);
}
I’m trying to flip my sprite in 2D when moving towards different waypoints. I’ve tried to flip the localScale by adding a minus. I can see during runtime using Debug.log that the scale is constantly flipping between 1 and -1 but in the inspector and visually there’s no change at all.
Any ideas where I’m going wrong?
Thanks