I can’t seem to figure out why keyboard input isnt being captured for the player movement. Nothing is going to the Debug.Log so im assuming its my code or mapping but cant see where … Player sprite has rigid body and Player Controller script assigned to it
PlayerController Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private float moveSpeed = 1f;
private PlayerControls playerControls;
private Vector2 movement;
private Rigidbody2D rb;
private void Awake() {
playerControls = new PlayerControls();
rb = GetComponent<Rigidbody2D>();
}
private void OnEnable() {
playerControls.Enable();
}
private void OnDisable() {
playerControls.Disable();
}
private void Update() {
PlayerInput();
}
private void FixedUpdate() {
Move();
}
private void PlayerInput() {
movement = playerControls.Movement.Move.ReadValue<Vector2>();
Debug.Log(movement.x);
}
private void Move() {
rb.MovePosition(rb.position + movement * (moveSpeed * Time.fixedDeltaTime));
}
}