@cem_ck Hi there, I don’t think CMV done done at the moment, it is still in active development and think it would take for a while, for just clutch, I don’t think you really need it at the moment especially if your product is in active development as well.
Building the cart while train is moving is not the best idea or you have to take responsibility that it can break. However at the same time as I see clutch module is fairly done in CMV depending on the child modules speed so there is no big dependency overall specifically for clutch module. That can give you some space to make a decision.
However even from the core engine module a clutch is
void FClutchSimModule::Simulate(float DeltaTime, const FAllInputs& Inputs, FSimModuleTree& VehicleModuleSystem)
{
//FTorqueSimModule* Parent = static_cast<FTorqueSimModule*>(GetParent());
//FTorqueSimModule* Child = static_cast<FTorqueSimModule*>(GetFirstChild());
//float EngineSpeed = Parent->GetAngularVelocity();
//float TransmissionSpeed = Child->GetAngularVelocity();
//// difference in speed between the two plates
//float AngularVelocityDifference = EngineSpeed - TransmissionSpeed;
// Inputs.Clutch 0 is engaged/locked, 1 is depressed/open
ClutchValue = (1.0f - Inputs.GetControls().GetMagnitude(ClutchControlName)) * Setup().ClutchStrength;
FTorqueSimModule* Parent = static_cast<FTorqueSimModule*>(GetParent());
FTorqueSimModule* Child = static_cast<FTorqueSimModule*>(GetFirstChild());
if (Parent && Child)
{
float EngineSpeed = Parent->GetAngularVelocity();
float TransmissionSpeed = Child->GetAngularVelocity();
// difference in speed between the two plates
float AngularVelocityDifference = EngineSpeed - TransmissionSpeed;
Parent->AddAngularVelocity(-AngularVelocityDifference * 0.1f);
Child->AddAngularVelocity(AngularVelocityDifference * 0.1f);
float BrakeTorque = 0.0f;
TransmitTorque(VehicleModuleSystem, DriveTorque, BrakeTorque, 1.0f, ClutchValue);
}
}
As we can see it gets the first child , they look the delta difference between the angular velocities (slip) and make addition/substraction to angular velocities (even it’s hardcoded so there is no clutch effectiveness at the moment)
Parent->AddAngularVelocity(-AngularVelocityDifference * 0.1f);
Child->AddAngularVelocity(AngularVelocityDifference * 0.1f);
You can do same system for any vehicle in any system. Think Epic when time is right will add some stuff over here aswell since this is not a super nice clutch at the current state but more likely a spring constraint without spring.
I would possibly add some parameters as,
A Clutch Curve : Defining its effectiveness on press how much it try propagate energy.
A Clutch Friction : Defining how much force it generates at the very moment.
A Scalar Multiplier for Mass : Defining how much parent and child masses considered during the clutch solve. Since sometimes as gameplay we would want to neglect portion of the parent/child mass. This can be default 1 and this would be a quality of life variable.
Some Limiters : Maybe some max clutch force limiters can be nice over here not exceeding total torque on parent body because without limits it can achieve full authority so better have those by design.
Edit : At a second thought since changing the model over here with these thoughts, adding a very brief state machine (Free, Partial, Locked) over here would make sense and it would be a more elegant model.
Think wouldn’t be adding more besides this like energy conservation etc. since would be too specific at least in my opinion. With these it would be possible to mimic a realistic behaviour in clutch putting inertial forces on the parent body (car) like engine stall.
Let us know if this is good enough insights around it.