/
SomeOneDay
/
UnityLesson
Обзор
Документация
Войти
/
SomeOneDay
/
UnityLesson
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
GAME/Assets/Scripts/Player.cs
53 строки
1 KB
weeny
first commit
01 мар 2026, 17:01
01 мар 2026, 17:01
fb4adfb
Код
Авторство
О чём код?
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public static Player Instance { get; private set; } [SerializeField] private float movingSpeed = 10f; private Rigidbody2D rb; private float minMovingSpeed = 0.1f; private bool isRunning = false; private void Awake() { rb = GetComponent<Rigidbody2D>(); Instance = this; } private void FixedUpdate() { HandelMovement(); } private void HandelMovement() { Vector2 inputVector = GameInput.Instance.GetMovementVector(); Debug.Log(inputVector); rb.MovePosition(rb.position + inputVector * (movingSpeed * Time.fixedDeltaTime)); if (Mathf.Abs(inputVector.x) > minMovingSpeed || (Mathf.Abs(inputVector.y) > minMovingSpeed)){ isRunning = true; Debug.Log(isRunning); } else { isRunning = false; Debug.Log(isRunning); } } public bool IsRunning() { Debug.Log("IsRunning Вызван"); return isRunning; } // Добовляем метод запроса позиции играка на экране public Vector3 GetPlayerScreenPosition() { Vector3 playerScreenPosition = Camera.main.WorldToScreenPoint(transform.position); return playerScreenPosition; } }