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 » 06 Feb 2025, 05:24

Hey, ich habe dem Unity Rollball Tuto verfolgt, aber meine OnMove -Funktion scheint nicht zu sein, dann wird sich mein Spieler in Unity nicht bewegen. ;
Verwenden Sie UnityEngine.inputSystem; < /p>

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);
}
}


Top