Merge branch 'master' of git@ooftooft.net:Racesm.git

# Conflicts:
#	Assets/ML-Agents/Timers/Racetrack mini_timers.json
This commit is contained in:
PokingPines
2024-04-24 17:50:28 +02:00
55 changed files with 144624 additions and 2428 deletions

View File

@@ -47,8 +47,8 @@ public class AgentController: Agent
// Find all child GameObjects that have the WheelControl script attached
wheels = GetComponentsInChildren<WheelControl>();
startPosition = transform.localPosition;
startRotation = transform.localRotation;
startPosition = transform.position;
startRotation = transform.rotation;
}
@@ -76,21 +76,20 @@ public class AgentController: Agent
// reset car
transform.localPosition = startPosition;
transform.localRotation = startRotation;
transform.position = startPosition;
transform.rotation = startRotation;
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
//randomize car position
// //randomize car position
float rng = UnityEngine.Random.Range(-3f, 3f);
// int rng = UnityEngine.Random.(-3, 3);
// float rng = UnityEngine.Random.Range(-3f, 3f);
transform.localPosition = new Vector3(
transform.localPosition.x,
transform.localPosition.y,
transform.localPosition.z + rng
);
// transform.position = new Vector3(
// transform.position.x,
// transform.position.y,
// transform.position.z + rng
// );
@@ -114,8 +113,8 @@ public class AgentController: Agent
sensor.AddObservation(angleToCheckpoint(currentCheckpoint));
// relative vector pointing to checkpoint
Vector3 position = transform.localPosition;
Vector3 checkpointPosition = currentCheckpoint.localPosition;
Vector3 position = transform.position;
Vector3 checkpointPosition = currentCheckpoint.position;
Vector3 toCheckpoint = new Vector3(
checkpointPosition.x - position.x,
@@ -123,7 +122,7 @@ public class AgentController: Agent
checkpointPosition.z - position.z
);
float carAngle = transform.localEulerAngles.y;
float carAngle = transform.eulerAngles.y;
toCheckpoint = Quaternion.Euler(0, -carAngle, 0) * toCheckpoint.normalized;
@@ -353,7 +352,7 @@ public class AgentController: Agent
float angleToCheckpoint(Transform checkpoint)
{
Vector3 checkpointDirection = checkpoint.localPosition - transform.localPosition;
Vector3 checkpointDirection = checkpoint.position - transform.position;
float angle = Vector3.SignedAngle(transform.forward, checkpointDirection, Vector3.up);
return angle;

View File

@@ -22,7 +22,7 @@ public class CarLoader : MonoBehaviour
}
catch (System.Exception)
{
carType = "Racecar";
carType = "Bulldozer";
carColor = "Default";
print("no loading");
}

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LapTimer : MonoBehaviour
{
public float time = 0;
private bool startTime = false;
private void OnTriggerEnter(Collider other) {
if (startTime)
{
startTime = false;
print(time);
} else {
startTime = true;
time=0;
}
}
void FixedUpdate()
{
time +=1;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 78b183b93b28716489abc7e12d0ee15f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -122,13 +122,13 @@ public class PlayerController : MonoBehaviour
}
private void Update() {
Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
// Transform currentCheckpoint = checkpoints[checkpointsCollected].transform;
// float checkpintDistance = distanceToCheckpoint(currentCheckpoint);
if (checkpintDistance < 0.1f)
{
checkpointsCollected += 1;
}
// if (checkpintDistance < 0.1f)
// {
// checkpointsCollected += 1;
// }
}
private void OnCollisionEnter(Collision other) {