Die Funktion des Einheitseingangssystems Onmove ist ungenutzt
Posted: 14 Apr 2025, 11:51
Hey, ich habe das Tutorial der Unity Roll -Ball gefolgt, aber meine OnMove -Funktion scheint unbenutzt zu sein, dann wird sich mein Spieler nicht in Einheit bewegen.
Einheit Windows
Code: Select all
using UnityEngine;
using UnityEngine.InputSystem;
public class playerController : MonoBehaviour
{
private Rigidbody rb;
private float moveX;
private float moveY;
// Start is called before the first frame update
void Start()
{
rb = GetComponent(); //ref to player's rigidbody
}
void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get();
moveX = movementVector.x;
moveY = movementVector.y;
}
private void FixedUpdate()
{
Vector3 movement = new Vector3(moveX, 0.0f, moveY);
rb.AddForce(movement);
}
}