0 votes
by
retagged by
How do I simulate an engine failure while driving?

1 Answer

0 votes
by
 
Best answer

You may use the allowedFuelRatio property of the Engine block. Values between 0 and 1 are accepted. 0 cuts all the power of the engine, and 1 means normal operation. You may even pass a value coming from a noise function to simulate a failing engine.

This simulates a completely failed engine:

Engine engine = vehicle.GetInternalObject(typeof(Engine));
engine.allowedFuelRatio = 0.0f;

Notes:

  • Not all vehicles have a combustion engine (i.e. trailers, electric vehicles). GetInternalObject will return null in these vehicles.
  • This feature is not available in the Community Edition. GetInternalObject always returns null.
...