protected override void DoDriverDeath() { // just enable physics for this vehicle SetKinematic(false); // set its velocity VehicleRigidbody.velocity = velocity; // and add random torque float maxTorque = deathTorque; float t = Random.Range(-maxTorque, maxTorque); VehicleRigidbody.AddTorque(t * VehicleRigidbody.mass * transform.up, ForceMode.Impulse); }
protected override void DoDriverDeath() { // just enable physics for this vehicle SetKinematic(false); // set its velocity VehicleRigidbody.velocity = velocity; // and add random torque const float maxTorqueZ = 70; const float minTorqueY = -30; const float maxTorqueY = 50; float z = Random.Range(-maxTorqueZ, maxTorqueZ); float y = -Random.Range(minTorqueY, maxTorqueY); float mass = VehicleRigidbody.mass; Vector3 torque = z * mass * transform.forward + y * mass * transform.right; VehicleRigidbody.AddTorque(torque, ForceMode.Impulse); }