using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotat : MonoBehaviour
{
public SpriteRenderer Hero;
public SpriteRenderer Sh;
private void Update()
{
if (Hero.flipX == true)
{
Sh.flipX = true;
transform.position += new Vector3(3, 0);
}
if (Hero.flipX == false)
{
Sh.flipX = false;
}
}
}
float _inputX;
float _inputLastInput=1;
private void Update()
{
_inputX = Input.GetAxisRaw("Horizontal");
Mover();
}
private void Mover()
{
if (_inputX == 0) return;
if (_inputLastInput != _inputX) RotObj();
transform.position+=transform.right*Time.deltaTime;
}
void RotObj()
{
_inputLastInput *= -1;
float angle = 180;
if (_inputLastInput == 1) angle = 0;
transform.rotation = Quaternion.Euler(0,angle,0);
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotat : MonoBehaviour
{
public SpriteRenderer Hero;
public SpriteRenderer Sh;
public bool Blocking = false;
private void Update()
{
if (Blocking == false)
{
if (Hero.flipX == true)
{
Sh.flipX = true;
transform.position += new Vector3(3, 0);
}
if (Hero.flipX == false)
{
Sh.flipX = false;
}
Blocking = true;
}
}
}