using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Управление : MonoBehaviour
{
Rigidbody2D rb;
Animator anim;
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space)) {
}
if (Input.GetAxis("Horizontal") == 0)
{
anim.SetInteger("stay", 1);
} else {
Flip();
anim.SetInteger("stay", 2);
}
}
void Flip()
{
if (Input.GetAxis ("Horizontal") < 0)
transform.localRotation = Quaternion.Euler(0, 0, 0);
if (Input.GetAxis("Horizontal") > 0)
transform.localRotation = Quaternion.Euler(0, 180, 0);
}
}
void FixedUpdate()
{
rb.velocity = new Vector2(Input.GetAxis("Horizontal") * 12f, rb.velocity.y);
}
void jump()
{
rb.AddForce(transform.up * 14f, ForceMode2D.Impulse);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Управление : MonoBehaviour
{
Rigidbody2D rb;
Animator anim;
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
}
if (Input.GetAxis("Horizontal") == 0)
{
anim.SetInteger("stay", 1);
}
else
{
Flip();
anim.SetInteger("stay", 2);
}
}
void Flip()
{
if (Input.GetAxis("Horizontal") < 0)
transform.localRotation = Quaternion.Euler(0, 0, 0);
if (Input.GetAxis("Horizontal") > 0)
transform.localRotation = Quaternion.Euler(0, 180, 0);
}
void FixedUpdate()
{
rb.velocity = new Vector2(Input.GetAxis("Horizontal") * 12f, rb.velocity.y);
}
void jump()
{
rb.AddForce(transform.up * 14f, ForceMode2D.Impulse);
}
}