Tp3 + start TP4
This commit is contained in:
parent
57a40d426b
commit
3a7ce962e7
112 changed files with 63386 additions and 45 deletions
8
TP3/Assets/Scripts/CameraThings.meta
Normal file
8
TP3/Assets/Scripts/CameraThings.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6f3ba7d951c13d94e8c0b04d43b32b00
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
23
TP3/Assets/Scripts/CameraThings/FollowTarget.cs
Normal file
23
TP3/Assets/Scripts/CameraThings/FollowTarget.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class FollowTarget : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform target;
|
||||
[SerializeField]
|
||||
[Range(0f, 1f)]
|
||||
float lerpSpeed;
|
||||
|
||||
Vector3 offset;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
offset = transform.position - target.position;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
transform.position = Vector3.Lerp(transform.position, target.position + offset, lerpSpeed);
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/CameraThings/FollowTarget.cs.meta
Normal file
2
TP3/Assets/Scripts/CameraThings/FollowTarget.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4a9106350d857124a863205f6cb4888d
|
8
TP3/Assets/Scripts/CarThings.meta
Normal file
8
TP3/Assets/Scripts/CarThings.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c242aa901ec83f24eb48233243429b61
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
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
|
34
TP3/Assets/Scripts/PlatformMove.cs
Normal file
34
TP3/Assets/Scripts/PlatformMove.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PlatformMove : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform start;
|
||||
[SerializeField] Transform end;
|
||||
[SerializeField]
|
||||
[Range(0.5f, 10f)]
|
||||
float loop_time;
|
||||
|
||||
float t;
|
||||
float direction = 1.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 FixedUpdate()
|
||||
{
|
||||
t += Time.fixedDeltaTime * direction;
|
||||
transform.position = Vector3.Lerp(start.position, end.position, t / loop_time);
|
||||
if (t > loop_time)
|
||||
{
|
||||
direction *= -1;
|
||||
}
|
||||
if (t < 0)
|
||||
{
|
||||
direction = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
2
TP3/Assets/Scripts/PlatformMove.cs.meta
Normal file
2
TP3/Assets/Scripts/PlatformMove.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ecda1db2e1644334a85384ddb45f7620
|
19
TP3/Assets/Scripts/Rocket.cs
Normal file
19
TP3/Assets/Scripts/Rocket.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Rocket : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
[SerializeField] Vector3 initVelocitity;
|
||||
Rigidbody rb;
|
||||
void Start()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
rb.linearVelocity += transform.rotation * initVelocitity;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/Rocket.cs.meta
Normal file
2
TP3/Assets/Scripts/Rocket.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0caaa457ebb4027488664a4c450d79e2
|
26
TP3/Assets/Scripts/RocketLauncher.cs
Normal file
26
TP3/Assets/Scripts/RocketLauncher.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class RocketLauncher : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject rocketPrefab;
|
||||
[SerializeField] Transform spawnTransform;
|
||||
[SerializeField] Rigidbody car;
|
||||
// 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()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
GameObject rocket = GameObject.Instantiate(rocketPrefab);
|
||||
rocket.transform.position = spawnTransform.position;
|
||||
rocket.transform.forward = transform.forward;
|
||||
Rigidbody rb = rocket.GetComponent<Rigidbody>();
|
||||
rb.linearVelocity = car.linearVelocity;
|
||||
}
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/RocketLauncher.cs.meta
Normal file
2
TP3/Assets/Scripts/RocketLauncher.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 284b6aab568dfee469b40a54ccbdf362
|
26
TP3/Assets/Scripts/UIManager.cs
Normal file
26
TP3/Assets/Scripts/UIManager.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] TextMeshProUGUI timeText;
|
||||
[SerializeField] TextMeshProUGUI velocityText;
|
||||
[SerializeField] Rigidbody car;
|
||||
|
||||
// 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()
|
||||
{
|
||||
int minute = (int) Time.time / 60;
|
||||
int secondes = (int) Time.time % 60;
|
||||
timeText.text = $"Time : {minute} min {secondes}s";
|
||||
|
||||
int velocity = (int) car.linearVelocity.magnitude;
|
||||
velocityText.text = $"{velocity} m/s";
|
||||
}
|
||||
}
|
2
TP3/Assets/Scripts/UIManager.cs.meta
Normal file
2
TP3/Assets/Scripts/UIManager.cs.meta
Normal file
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 377823b7918eb214598f5116386cfb1e
|
Loading…
Add table
Add a link
Reference in a new issue