Tp3 + start TP4
This commit is contained in:
parent
57a40d426b
commit
3a7ce962e7
112 changed files with 63386 additions and 45 deletions
23
TP3/Assets/Scripts/CarThings/Boost.cs
Normal file
23
TP3/Assets/Scripts/CarThings/Boost.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/CarThings/Boost.cs.meta
Normal file
2
TP3/Assets/Scripts/CarThings/Boost.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a276015e3cc1ab842bddeb19a3fe669b
|
30
TP3/Assets/Scripts/CarThings/CarMove.cs
Normal file
30
TP3/Assets/Scripts/CarThings/CarMove.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
2
TP3/Assets/Scripts/CarThings/CarMove.cs.meta
Normal file
2
TP3/Assets/Scripts/CarThings/CarMove.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6400911a004f105448da303209ad0c5d
|
34
TP3/Assets/Scripts/CarThings/RotateWithMouse.cs
Normal file
34
TP3/Assets/Scripts/CarThings/RotateWithMouse.cs
Normal 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/CarThings/RotateWithMouse.cs.meta
Normal file
2
TP3/Assets/Scripts/CarThings/RotateWithMouse.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 679fdbf2f63e99f418083aa619eab571
|
35
TP3/Assets/Scripts/CarThings/speedZone.cs
Normal file
35
TP3/Assets/Scripts/CarThings/speedZone.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/CarThings/speedZone.cs.meta
Normal file
2
TP3/Assets/Scripts/CarThings/speedZone.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6791b6b11b5f46c4091c7e01d22104aa
|
Loading…
Add table
Add a link
Reference in a new issue