using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class GamerDvijenie : MonoBehaviour {
public Rigidbody2D rb2d;
public float playerSpeed;
public int directionInput;
public bool groundCheck;
public bool facingRight = true;
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
}
void Update()
{
if ((directionInput < 0) && (facingRight))
{
Flip();
}
if ((directionInput > 0) && (!facingRight))
{
Flip();
}
if (directionInput == 0)
{
}
groundCheck = true;
}
void FixedUpdate()
{
rb2d.velocity = new Vector2(playerSpeed * directionInput, rb2d.velocity.y);
}
public void Move(int InputAxis)
{
directionInput = InputAxis;
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale; - делает спрайт зеркальным при двежении в лево и в право соответсвенно, не нужно просто стираем
theScale.x *= -1; - делает спрайт зеркальным при двежении в лево и в право соответсвенно если не нужно просто стираем
transform.localScale = theScale; - делает спрайт зеркальным при двежении в лево и в право соответсвенно если не нужно просто стираем
}
}