50 lines
1.1 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public partial class PlayerMain : MonoBehaviour
{
public static PlayerMain Instance {get; private set;}
private PlayerInputHandler _input;
private Rigidbody2D _rigidbody2D;
private BoxCollider2D _collider2D;
private void Awake()
{
if (Instance != null)
{
Debug.Log(name + " already exist! " + transform);
Destroy(gameObject);
return;
}
Instance = this;
_input = GetComponent<PlayerInputHandler>();
_rigidbody2D = GetComponent<Rigidbody2D>();
_collider2D = GetComponent<BoxCollider2D>();
}
private void Start()
{
_input.OnJumpTrigger += Input_OnJumpTrigger;
_footOffset = _collider2D.size.x / 2f;
_facingDir = visualTransform.localScale.x >= 0f ? 1f : -1f;
}
private void Update()
{
PhysicsCheck();
}
private void FixedUpdate()
{
MovementHandler();
FacingDir();
}
}