This commit is contained in:
zmoixdev
2026-03-07 14:35:00 -07:00
parent 8506da9f51
commit adf2969156
26 changed files with 2358 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;
public class CharacterMovementCotroller : MonoBehaviour
{
[SerializeField] float driveSpeed = 10f;
[SerializeField] float turnSpeed = 1000f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
EvaluateMovementInput();
}
private Vector3 turnLeft = new Vector3(0, -1, 0);
private Vector3 turnRight = new Vector3(0, 1, 0);
void EvaluateMovementInput() {
Quaternion currentRotation = transform.rotation;
if (Keyboard.current.wKey.isPressed) {
Vector3 moveBy = transform.forward * driveSpeed * Time.deltaTime;
transform.position += moveBy;
}
if (Keyboard.current.sKey.isPressed) {
Vector3 moveBy = transform.forward * -1 * driveSpeed * Time.deltaTime;
transform.position += moveBy;
}
if (Keyboard.current.aKey.isPressed) {
transform.Rotate(turnLeft * Time.deltaTime * turnSpeed);
}
if (Keyboard.current.dKey.isPressed) {
transform.Rotate(turnRight * Time.deltaTime * turnSpeed);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 30b89096a634b634ea818091dae0462f