Pathfinding Updates
- Improved Navigation / Path Generation * Still need to set up the agent radius to fit the arm or whatever dynamic component on a robot
This commit is contained in:
parent
966c3ed39d
commit
cbb0bc5fc2
@ -324,3 +324,4 @@ MaxAgentRadius=100.000000
|
|||||||
+ActiveGameNameRedirects=(OldGameName="/Script/TP_VehicleAdv",NewGameName="/Script/LuckyWorldV2")
|
+ActiveGameNameRedirects=(OldGameName="/Script/TP_VehicleAdv",NewGameName="/Script/LuckyWorldV2")
|
||||||
+ActiveGameNameRedirects=(OldGameName="Luckyrobots",NewGameName="/Script/LuckyWorldV2")
|
+ActiveGameNameRedirects=(OldGameName="Luckyrobots",NewGameName="/Script/LuckyWorldV2")
|
||||||
+ActiveGameNameRedirects=(OldGameName="/Script/Luckyrobots",NewGameName="/Script/LuckyWorldV2")
|
+ActiveGameNameRedirects=(OldGameName="/Script/Luckyrobots",NewGameName="/Script/LuckyWorldV2")
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -59,6 +59,8 @@ void FRobotSplinePath::RegenerateSplinePathValues()
|
|||||||
constexpr float SplinePredictionTime = 1.f;
|
constexpr float SplinePredictionTime = 1.f;
|
||||||
constexpr float SplinePredictionDistanceMin = 64.f;
|
constexpr float SplinePredictionDistanceMin = 64.f;
|
||||||
const float SpeedLimit = GetRobot()->RobotSettings.SpeedLimit;
|
const float SpeedLimit = GetRobot()->RobotSettings.SpeedLimit;
|
||||||
|
const float TurnSpeedLimit = GetRobot()->RobotSettings.TurnSpeedLimit;
|
||||||
|
const float TurnSpeedMod = UKismetMathLibrary::SafeDivide(TurnSpeedLimit, SpeedLimit);
|
||||||
const float TargetSpeed = FMath::Min<float>(GetRobot()->GetTargetSpeed(), SpeedLimit);
|
const float TargetSpeed = FMath::Min<float>(GetRobot()->GetTargetSpeed(), SpeedLimit);
|
||||||
const float SplinePredictionDistance = FMath::Max<float>(SplinePredictionTime * TargetSpeed, SplinePredictionDistanceMin);
|
const float SplinePredictionDistance = FMath::Max<float>(SplinePredictionTime * TargetSpeed, SplinePredictionDistanceMin);
|
||||||
constexpr float TangentClamp = 128.f;
|
constexpr float TangentClamp = 128.f;
|
||||||
@ -103,13 +105,12 @@ void FRobotSplinePath::RegenerateSplinePathValues()
|
|||||||
GetSplinePath()->UpdateSpline();
|
GetSplinePath()->UpdateSpline();
|
||||||
const float SplineLength = GetSplinePath()->GetSplineLength();
|
const float SplineLength = GetSplinePath()->GetSplineLength();
|
||||||
SplinePathSpeedModifier.EditorCurveData.Reset();
|
SplinePathSpeedModifier.EditorCurveData.Reset();
|
||||||
constexpr float MinSpeedMod = 0.2f;
|
constexpr float MinSpeedMod = 0.4f;
|
||||||
constexpr float SplinePrecision = 10.f;
|
constexpr float SplinePrecision = 10.f;
|
||||||
|
|
||||||
if (bSingleInput)
|
if (bSingleInput)
|
||||||
{
|
{
|
||||||
constexpr float SectionSpeedMod = 0.4f;
|
const float SectionSpeedClamp = FMath::Min<float>(SpeedLimit * MinSpeedMod, TargetSpeed);
|
||||||
const float SectionSpeedClamp = FMath::Min<float>(SpeedLimit * SectionSpeedMod, TargetSpeed);
|
|
||||||
const float DecelerationStep = SplinePredictionDistance + SplinePrecision;
|
const float DecelerationStep = SplinePredictionDistance + SplinePrecision;
|
||||||
SplinePathSpeedModifier.EditorCurveData.AddKey(0.f, SectionSpeedClamp);
|
SplinePathSpeedModifier.EditorCurveData.AddKey(0.f, SectionSpeedClamp);
|
||||||
SplinePathSpeedModifier.EditorCurveData.AddKey(SplineLength, TargetSpeed * MinSpeedMod);
|
SplinePathSpeedModifier.EditorCurveData.AddKey(SplineLength, TargetSpeed * MinSpeedMod);
|
||||||
@ -170,10 +171,11 @@ void FRobotSplinePath::RegenerateSplinePathValues()
|
|||||||
const float DistanceToPathEnd = SplineLength - SplineDistance;
|
const float DistanceToPathEnd = SplineLength - SplineDistance;
|
||||||
const float PathEndMod = DistanceToPathEnd <= SplinePredictionDistance ? FMath::Max<float>(UKismetMathLibrary::SafeDivide(DistanceToPathEnd, SplinePredictionDistance), 0.f) : 1.f;
|
const float PathEndMod = DistanceToPathEnd <= SplinePredictionDistance ? FMath::Max<float>(UKismetMathLibrary::SafeDivide(DistanceToPathEnd, SplinePredictionDistance), 0.f) : 1.f;
|
||||||
const FVector IntervalTangent = GetSplinePath()->GetTangentAtDistanceAlongSpline(SplineDistance, ESplineCoordinateSpace::Local);
|
const FVector IntervalTangent = GetSplinePath()->GetTangentAtDistanceAlongSpline(SplineDistance, ESplineCoordinateSpace::Local);
|
||||||
const float IntervalCurve = FMath::Min<float>(IntervalTangent.Length(), TangentClamp);
|
const float IntervalCurve = FMath::Min<float>(TangentClamp, IntervalTangent.Length());
|
||||||
const float IntervalAlpha = FMath::Max<float>(1.f - UKismetMathLibrary::SafeDivide(IntervalCurve, TangentClamp), 0.f);
|
const float IntervalAlpha = FMath::Max<float>(1.f - UKismetMathLibrary::SafeDivide(IntervalCurve, TangentClamp), 0.f);
|
||||||
const float SpeedMod = (MaxSpeedMod - IntervalAlpha) * PathEndMod;
|
const float SpeedMod = (MaxSpeedMod - IntervalAlpha) * PathEndMod;
|
||||||
const float ClampedSpeed = FMath::Max<float>(SpeedLimit * SpeedMod, SpeedLimit * MinSpeedMod);
|
const float ClampedSpeed = FMath::Max<float>(SpeedLimit * SpeedMod, SpeedLimit * TurnSpeedMod);
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("SpeedMod :: (%f - %f) * %f = %f"), MaxSpeedMod, IntervalAlpha, PathEndMod, SpeedMod);
|
||||||
SplinePathSpeedModifier.EditorCurveData.AddKey(SplineDistance, ClampedSpeed);
|
SplinePathSpeedModifier.EditorCurveData.AddKey(SplineDistance, ClampedSpeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,9 @@ struct FRobotSettings
|
|||||||
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Robot Settings")
|
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Robot Settings")
|
||||||
float SpeedLimit = 15.f;
|
float SpeedLimit = 15.f;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Robot Settings")
|
||||||
|
float TurnSpeedLimit = 10.f;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Robot Settings")
|
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Robot Settings")
|
||||||
TSubclassOf<AMujocoVolumeActor> MujocoSettings;
|
TSubclassOf<AMujocoVolumeActor> MujocoSettings;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user