Ich versuche, den Würfel zu bewegen, wenn ich die W -Taste und die S -Taste drücke. Alles funktioniert auf YouTube, aber
Posted: 03 Apr 2025, 09:54
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player2 : MonoBehaviour
{
[SerializeField] KeyCode keyOne;
[SerializeField] KeyCode keyTwo;
[SerializeField] Vector3 moveDirection;
private void FixedUpdate()
{
if (Input.GetKey(keyOne))
{
GetComponent().linearVelocity += moveDirection;
}
if (Input.GetKey(keyTwo))
{
GetComponent().linearVelocity -= moveDirection;
}
}
}