Initial commit: Unity project setup

This commit is contained in:
2026-03-25 16:26:24 +01:00
parent ba777e3fe6
commit c2c08569d4
61 changed files with 6743 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.InputSystem;
public class BallController : MonoBehaviour {
private float ballSpeed;
private float brakeForce;
private float jumpForce;
private Rigidbody rb;
float outOfBounds = -1.8f;
public void Start() {
rb = GetComponent<Rigidbody>();
ballSpeed = 3f;
brakeForce = 0.3f;
jumpForce = 14f;
}
private void Update() {
KeyHandler();
CheckPlayerOut();
}
void CheckPlayerOut() {
if (transform.position.y < outOfBounds) {
transform.position = new Vector3(0, 1f, 0);
transform.rotation = Quaternion.Euler(0, 0, 0);
}
}
public void KeyHandler() {
if (Keyboard.current.wKey.isPressed) {
rb.AddForce(Vector3.forward * ballSpeed);
}
else if (Keyboard.current.sKey.isPressed) {
rb.AddForce(Vector3.back * ballSpeed);
}
else if (Keyboard.current.dKey.isPressed) {
rb.AddForce(Vector3.right * ballSpeed);
}
else if (Keyboard.current.aKey.isPressed) {
rb.AddForce(Vector3.left * ballSpeed);
}
if (Keyboard.current.spaceKey.isPressed && transform.position.y < 1) {
Debug.Log("KrossKross will make you...");
rb.AddForce(Vector3.up * jumpForce);
}
else {
rb.AddForce(-rb.linearVelocity * brakeForce);
}
}
}