by Anonymous » 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;
}
}
}
Dieser Code war genau das, was in der Lektion auf YouTube war, wo sich der Würfel auf und ab bewegt, aber für mich bewegt sich es nicht mit derselben Schaltfläche Einstellung.Unity 6000.0.44f1
[code]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;
}
}
}
[/code]
Dieser Code war genau das, was in der Lektion auf YouTube war, wo sich der Würfel auf und ab bewegt, aber für mich bewegt sich es nicht mit derselben Schaltfläche Einstellung.Unity 6000.0.44f1