D
D
Dimproks2019-04-14 16:40:34
Unity
Dimproks, 2019-04-14 16:40:34

How to instantly stop the Unity machine?

Good afternoon!
The question arose, how to instantly stop a car that is traveling at a fairly low speed using wheelColliders?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Ivanov, 2019-04-14
@Dimproks

Pressing the space bar

public WheelCollider[] Cols;
public float brakeT = 100;

if (Input.GetKeyDown("space"))
{
            for(int i = 0; i < 4; i++)
            { 
                    Cols[i].brakeTorque = Mathf.Abs(Cols[i].motorTorque) * brakeT;
            }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question