Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
public void Save() { string key = “LvlNomer”; PlayerPrefs.SetInt(key, this.lvl); PlayerPrefs.Save(); }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CharController : MonoBehaviour { public Rigidbody2D rb2d; public float playerSpeed; public float jumpPower; public int directionInput; public bool groundCheck; public bool facingRight = true; public Animator _animator; public bool AnimTest; public int lvl; void Start() { rb2d = GetComponent<Rigidbody2D>(); _animator = GetComponent<Animator>(); } void Update() { if ((directionInput < 0) && (facingRight)) { Flip(); } if ((directionInput > 0) && (!facingRight)) { Flip(); } } public void Save() { string key = “LvlNomer”; PlayerPrefs.SetInt(key, this.lvl); PlayerPrefs.Save(); } public void Anim_run() { AnimTest = true; _animator.SetBool("Anim", AnimTest); } public void Anim_stop() { AnimTest = false; _animator.SetBool("Anim", AnimTest); } void FixedUpdate() { rb2d.velocity = new Vector2(playerSpeed * directionInput, rb2d.velocity.y); } public void Move(int InputAxis) { directionInput = InputAxis; } public void Jump(bool isJump) { isJump = groundCheck; if (groundCheck) { rb2d.velocity = new Vector2(rb2d.velocity.x, jumpPower); } } void OnTriggerStay2D(Collider2D col) { if (col.tag == "ground") groundCheck = true; } void OnTriggerExit2D(Collider2D col) { if (col.tag == "ground") groundCheck = false; } void Flip() { facingRight = !facingRight; Vector3 theScale = transform.localScale; theScale.x *= -1; transform.localScale = theScale; } }