Ошибка в юнити
Assets\Scripts\PlayerMove.cs(47,13): warning CS1717: Assignment made to same variable; did you mean to assign something else?. Писал код на поворот
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
public Rigidbody2D rb;
public Animator anim;
public SpriteRenderer sr;
public Vector2 moveVector;
public float speed = 2f;
public bool faceRight = true;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
sr = GetComponent<SpriteRenderer>();
}
// Update is called once per frame
void Update()
{
walk();
// Flip();
Reflect();
}
void walk()
{
moveVector.x = Input.GetAxis("Horizontal");
anim.SetFloat("moveX", Mathf.Abs(moveVector.x));
rb.velocity = new Vector2(moveVector.x * speed, rb.velocity.y);
//rb.AddForce(moveVector * speed);
}
// void Flip()
// {
// sr.flipX = moveVector.x < 0;
//}
void Reflect()
{
if ((moveVector.x > 0 && !faceRight) || (moveVector.x < 0 && faceRight))
{
transform.localScale *= new Vector2(-1, 1);
faceRight =faceRight;
}
}
}
Во-первых, не ошибка, а предупреждение.
Во-вторых: faceRight =faceRight;
И чего ты этим хотел добиться? Что за солипсизм?