Die Funktion des Einheitseingangssystems Onmove ist ungenutzt

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Die Funktion des Einheitseingangssystems Onmove ist ungenutzt

by Anonymous » 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.

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

Top