by Anonymous » 06 Feb 2025, 07:19
Hey, ich habe das Tutorial der Unity Roll Ball gefolgt, aber meine OnMove -Funktion scheint nicht genutzt zu werden, dann wird sich mein Spieler nicht in Einheit bewegen.
Dies ist mein Code:
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);
}
}
Einheit Windows
Hey, ich habe das Tutorial der Unity Roll Ball gefolgt, aber meine OnMove -Funktion scheint nicht genutzt zu werden, dann wird sich mein Spieler nicht in Einheit bewegen.
Dies ist mein Code:
[code]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);
}
}
[/code]
Einheit Windows