thank you , ill check out epics example, didnt realize it had a tyre track.
@joe1029
yes add it to the car template, the vehicle pawn it creates from the c++ version
heres everything you need to add
in your car.h, directly under GENERATED_UCLASS_BODY()
/** more slide than wea are skidding */
UPROPERTY(Category = Skid, EditAnywhere)
float SkidThreshold = 0.4;
/** tyre smoke particle, make a blueprint of class and add the particle in default properties */
UPROPERTY(EditAnywhere, Category = Skid)
UParticleSystem* SmokeParticle;
//skid trace, misleading name sorry, turned out you can get everything from the wheel class
void TraceSkid();
in your car.cpp, call TraceSkid() in Tick()
blah::Tick(..)
{
...... stuff already there...
TraceSkid();
}
void AC_CarPawn::TraceSkid()
{
// Simulation
UWheeledVehicleMovementComponent4W* Vehicle4W = CastChecked<UWheeledVehicleMovementComponent4W>(VehicleMovement);
//iterate through all the wheels
for (int32 Itr = 0; Itr < 4; Itr++)
{
//should prob use abs() or whatever
if (Vehicle4W->Wheels[Itr]->DebugLatSlip > SkidThreshold || Vehicle4W->Wheels[Itr]->DebugLongSlip > SkidThreshold || Vehicle4W->Wheels[Itr]->DebugLatSlip < -SkidThreshold || Vehicle4W->Wheels[Itr]->DebugLongSlip < -SkidThreshold)
{
//we iz skiddin
if (Vehicle4W->Wheels[Itr]->GetContactSurfaceMaterial()) //on the floor, will use GetContactSurfaceMaterial() later to change particle based on surface
{
//bottom of the wheel location
const FVector ParticleLoc = Vehicle4W->Wheels[Itr]->Location + FVector(0, 0, 1) * -(Vehicle4W->Wheels[0]->ShapeRadius / 2);
//spawn smoke particle
UGameplayStatics::SpawnEmitterAtLocation(, SmokeParticle, ParticleLoc, GetActorRotation());
}
}
}
}
GetContactSurfaceMaterial() is used in that function to test if the wheel is in contact with a surface, any surface, i plan to use it to get the surface type later, there is no need to do anything with materials or anything if you use it as is.