Tp3 + start TP4

This commit is contained in:
Crizomb 2024-12-10 13:14:30 +01:00
parent 57a40d426b
commit 3a7ce962e7
112 changed files with 63386 additions and 45 deletions

View file

@ -0,0 +1,23 @@
using UnityEngine;
public class Boost : MonoBehaviour
{
[SerializeField] Rigidbody rb;
[SerializeField] float boostMultiplier;
// 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()
{
// Middle click
if (Input.GetMouseButton(2))
{
rb.linearVelocity *= boostMultiplier;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a276015e3cc1ab842bddeb19a3fe669b

View file

@ -0,0 +1,30 @@
using UnityEngine;
public class CarMove : MonoBehaviour
{
public float speedModifier = 1.0f;
[SerializeField] float forwardMoveForce;
[SerializeField] float backwardMoveForce;
Rigidbody rb;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetMouseButton(0))
{
rb.AddForce(transform.forward * forwardMoveForce * speedModifier);
}
if (Input.GetMouseButton(1))
{
rb.AddForce(-transform.forward * backwardMoveForce * speedModifier);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6400911a004f105448da303209ad0c5d

View file

@ -0,0 +1,34 @@
using UnityEngine;
public class RotateWithMouse : MonoBehaviour
{
[SerializeField] LayerMask layerToIgnore;
[SerializeField] Transform targetTransform;
[SerializeField]
[Range(0f, 1f)]
float lerpSpeed = 0.1f;
Rigidbody rb;
Camera cam;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rb = GetComponent<Rigidbody>();
cam = Camera.main;
}
// Update is called once per frame
void FixedUpdate()
{
Ray _ray = cam.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(_ray, out RaycastHit hitInfo, float.MaxValue, ~layerToIgnore))
{
Vector3 point = hitInfo.point;
Vector3 dir = (point - transform.position).normalized;
dir.y = 0f;
targetTransform.forward = Vector3.Lerp(targetTransform.forward, dir, lerpSpeed);
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 679fdbf2f63e99f418083aa619eab571

View file

@ -0,0 +1,35 @@
using UnityEngine;
public class speedZone : MonoBehaviour
{
[SerializeField] float speedBoost = 2.0f;
// 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()
{
}
// Can e be optimized with layers
private void OnTriggerEnter(Collider other)
{
CarMove car = other.GetComponent<CarMove>();
if (car != null)
{
car.speedModifier = speedBoost;
}
}
private void OnTriggerExit(Collider other)
{
CarMove car = other.GetComponent<CarMove>();
if (car != null)
{
car.speedModifier = 1.0f;
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6791b6b11b5f46c4091c7e01d22104aa