Ok so when you type ‘showdebug vehicle’ you are presented with data about the tires, especially important is the tire long and lat slip but i cannot access these variables from blueprint :(.
Can I make that variable public for use in blueprint?
I have found the specific script within the Unreal files, and i have also found the specific variables(longSlip and latSlip), however making it public to view is what i need help with, I tried simply making the void function public but that didn’t seem to help
I am currently looking at this code , as you can see there is the two varibles
const PxReal LatSlip = WheelsStates[w].lateralSlip;
const PxReal LongSlip = WheelsStates[w].longitudinalSlip;
but i cannot for the life of me find where WheelsStates[w] is set to make that public
void UWheeledVehicleMovementComponent::DrawDebug(UCanvas* Canvas, float& YL, float& YPos)
{
if (PVehicle == NULL)
{
return;
}
FPhysXVehicleManager* MyVehicleManager = GetWorld()->GetPhysicsScene()->GetVehicleManager();
MyVehicleManager->SetRecordTelemetry(this, true);
UFont* RenderFont = GEngine->GetSmallFont();
// draw drive data
{
Canvas->SetDrawColor(FColor::White);
float forwardSpeedKmH = GetForwardSpeed() * 3600.f / 100000.f; //convert from cm/s to km/h
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Speed (km/h): %d"), (int32)forwardSpeedKmH), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Steering: %f"), SteeringInput), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Throttle: %f"), ThrottleInput), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Brake: %f"), BrakeInput), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("RPM: %f"), GetEngineRotationSpeed()), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Gear: %d"), GetCurrentGear()), 4, YPos);
YPos += Canvas->DrawText(RenderFont, FString::Printf(TEXT("Drag: %.3f"), DebugDragMagnitude), 4, YPos);
}
SCOPED_SCENE_READ_LOCK(MyVehicleManager->GetScene());
PxWheelQueryResult* WheelsStates = MyVehicleManager->GetWheelsStates_AssumesLocked(this);
check(WheelsStates);
// draw wheel data
for (uint32 w = 0; w < PVehicle->mWheelsSimData.getNbWheels(); ++w)
{
const PxMaterial* ContactSurface = WheelsStates[w].tireSurfaceMaterial;
const PxReal TireFriction = WheelsStates[w].tireFriction;
const PxReal LatSlip = WheelsStates[w].lateralSlip;
const PxReal LongSlip = WheelsStates[w].longitudinalSlip;
const PxReal WheelSpeed = PVehicle->mWheelsDynData.getWheelRotationSpeed(w) * PVehicle->mWheelsSimData.getWheelData(w).mRadius;
UPhysicalMaterial* ContactSurfaceMaterial = ContactSurface ? FPhysxUserData::Get<UPhysicalMaterial>(ContactSurface->userData) : NULL;
const FString ContactSurfaceString = ContactSurfaceMaterial ? ContactSurfaceMaterial->GetName() : FString(TEXT("NONE"));
Canvas->SetDrawColor(FColor::White);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("%d]"), w), 4, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("LatSlip: %.3f"), LatSlip), YL * 4, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("LongSlip: %.3f"), LongSlip), YL * 12, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Speed: %d"), (int32)WheelSpeed), YL * 22, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Contact Surface: %s"), *ContactSurfaceString), YL * 74, YPos);
if ((int32)w < Wheels.Num())
{
UVehicleWheel* Wheel = Wheels[w];
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Load: %.3f"), Wheel->DebugNormalizedTireLoad), YL * 30, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Torque: %d"), (int32)Wheel->DebugWheelTorque), YL * 40, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Long Force: %d"), (int32)Wheel->DebugLongForce), YL * 50, YPos);
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Lat Force: %d"), (int32)Wheel->DebugLatForce), YL * 62, YPos);
}
else
{
Canvas->DrawText(RenderFont, TEXT("Wheels array insufficiently sized!"), YL * 50, YPos);
}
YPos += YL;
}
// draw wheel graphs
PxVehicleTelemetryData* TelemetryData = MyVehicleManager->GetTelemetryData_AssumesLocked();
if (TelemetryData)
{
const float GraphWidth(100.0f), GraphHeight(100.0f);
int GraphChannels] = {
PxVehicleWheelGraphChannel::eWHEEL_OMEGA,
PxVehicleWheelGraphChannel::eSUSPFORCE,
PxVehicleWheelGraphChannel::eTIRE_LONG_SLIP,
PxVehicleWheelGraphChannel::eNORM_TIRE_LONG_FORCE,
PxVehicleWheelGraphChannel::eTIRE_LAT_SLIP,
PxVehicleWheelGraphChannel::eNORM_TIRE_LAT_FORCE,
PxVehicleWheelGraphChannel::eNORMALIZED_TIRELOAD,
PxVehicleWheelGraphChannel::eTIRE_FRICTION
};
for (uint32 w = 0; w < PVehicle->mWheelsSimData.getNbWheels(); ++w)
{
float CurX = 4;
for (uint32 i = 0; i < ARRAY_COUNT(GraphChannels); ++i)
{
float OutX = GraphWidth;
DrawTelemetryGraph(GraphChannels*, TelemetryData->getWheelGraph(w), Canvas, CurX, YPos, GraphWidth, GraphHeight, OutX);
CurX += OutX + 10.f;
}
YPos += GraphHeight + 10.f;
YPos += YL;
}
}
DrawDebugLines();
}
This code is viewable at the directory
C:\Program Files (x86)\Epic Games\4.12\Engine\Source\Runtime\Engine\Private\Vehicles\WheeledVehicleMovementComponent