Untitled
unknown
csharp
a year ago
566 B
2
Indexable
Never
void Brakes() { RaycastHit hit; float carSpeed = Vector3.Dot(transform.forward, rb.velocity); for (int i = 0; i < tires.Length; i++) { if (Physics.Raycast(tires[i].position, -tires[i].transform.up, out hit, offset)) { Vector3 accelerationDirection = tires[i].forward; if (carSpeed > 0) { rb.AddForceAtPosition(-accelerationDirection * brakesForce, tires[i].position); } } } }