Вместо флип поворота телепортирует туда сюда то есть флип сам работает но не корректно

Using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;

[RequireComponent(typeof(Rigidbody2D))]

public class Hero : MonoBehaviour
{
private PhotonView view;
public float speed;
public float jumpForce;
private float moveInput;
public int jumps;
public int jumpsCount;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGround;
public Transform groundCheck;
public Joystick joystick;
private bool isGrounded;
private Animator anim;
public static Hero Instance { get; set; }

private Rigidbody2D rb;
private bool facingRight = true;

void Start()
{

rb = GetComponent();
jumpsCount = jumps;
anim = GetComponent();
view = GetComponent();
joystick = GameObject.Find(«Variable Joystick»).GetComponent();
}

void FixedUpdate()
{

if (!view.IsMine) return;

moveInput = joystick.Horizontal;
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
{
isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
}
if (moveInput == 0)
{
anim.SetBool(«isRun», false);
}
else
{
anim.SetBool(«isRun», true);
}

}
void Update()
{

if (isGrounded == true)
{
jumpsCount = jumps;

}
if (isGrounded == true)
{
anim.SetBool(«Jump», false);
}
else
{
anim.SetBool(«Jump», true);
}

}

void Flip()
{
facingRight = !facingRight;
Vector2 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
public void OnJumpButtonDown()
{

jumpsCount—;

if (jumpsCount > 0)
{
rb.velocity = Vector2.up * jumpForce;
}
else if (jumpsCount == 0 && isGrounded)
{
rb.velocity = Vector2.up * jumpForce;
}
}
void OnTriggerEnter2D(Collider2D other)
{

if (other.tag == «Respawn»)
{
SceneManager.LoadScene(1);
}
}

}

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *