public class skript3_1_1 : MonoBehaviour { public float Speed; public float Speed1; public float X, Y; public Vector2 Vector2; public Rigidbody2D Body; public Transform Rotation; public float power; public float gamp; public SpriteRenderer sprite; public GameObject pleer; public GameObject lava; public Text text; public string[] a = {}; public int ii = 0;
void Start() {
}
// Update is called once per frame void Update() { peremehenie(); Rotation.rotation = Quaternion.identity; }
public void peremehenie() { X = Input.GetAxis("Horizontal"); Y = Input.GetAxis("Vertical");
using UnityEngine.UI;
public class skript3_1_1 : MonoBehaviour
{
public float Speed;
public float Speed1;
public float X, Y;
public Vector2 Vector2;
public Rigidbody2D Body;
public Transform Rotation;
public float power;
public float gamp;
public SpriteRenderer sprite;
public GameObject pleer;
public GameObject lava;
public Text text;
public string[] a = {};
public int ii = 0;
void Start()
{
}
// Update is called once per frame
void Update()
{
peremehenie();
Rotation.rotation = Quaternion.identity;
}
public void peremehenie()
{
X = Input.GetAxis("Horizontal");
Y = Input.GetAxis("Vertical");
Vector2 = new Vector2(X, Y);
transform.Translate(Vector2 * Speed * Time.deltaTime);
if (Input.GetKeyDown( KeyCode.Space ) && gamp >= 0)
{
gamp--;
Body.AddForce(Vector2.up * power, ForceMode2D.Impulse);
}
if (X < 0)
{
sprite.flipX = true;
}
if (X > 0)
{
sprite.flipX = false;
}
}
public void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "platform")
{
gamp = 1;
}
if (collision.gameObject.tag == "melnica")
{
text.text = "звуки мельницы";
Debug.Log("hglcu");
}
}
public void OnTriggerStay2D(Collider2D collision)
{
if (collision.gameObject.tag == "melnica")
{
text.text = a[ii];
if (Input.GetKey(KeyCode.H))
{
ii++; Debug.Log("lf");
}
if (Input.GetKey(KeyCode.J) && ii = 8)
{
ii--;
}
else { }
if (ii > 7 )
{
ii = 0;
}
}
}