Global Game Jam 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

49 lines
1001 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Variables;
using NaughtyAttributes;
public class CharacterInputController : MonoBehaviour
{
[SerializeField,Header("References")]
private CharacterController2D m_characterController;
[SerializeField]
private Reference<bool> m_playerInput;
[SerializeField,BoxGroup("Settings")]
private float m_speed = 2.0f;
[ShowNonSerializedField]
private Vector2 m_movement;
[ShowNonSerializedField]
private bool m_jump;
public void OnMove(InputAction.CallbackContext context)
{
m_movement = context.ReadValue<Vector2>();
}
public void OnJump(InputAction.CallbackContext context)
{
m_jump = context.ReadValueAsButton();
}
private void Update()
{
m_characterController.Move(m_movement.x * m_speed,false ,m_jump);
m_playerInput.Value = m_movement.magnitude != 0 || m_jump;
}
}