Tp3 + start TP4
This commit is contained in:
parent
57a40d426b
commit
3a7ce962e7
112 changed files with 63386 additions and 45 deletions
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue