Hello, it's me again.
Code: FCollisionQueryParams Params; // Ignore the player's pawn
// The hit result gets populated by the line trace
// Raycast out from the camera, only collide with pawns (they are on the ECC_Pawn collision channel)
FVector Start = thruster->GetComponentLocation();
FVector End = Start + (thruster->GetUpVector() * (traceLength*-1));
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECC_Pawn, Params);
// Hit.Actor contains a weak pointer to the Actor that the trace hit
FVector step1 = Hit.Location - thruster->GetComponentLocation();
float vectorLength = step1.Size();
float alpha = vectorLength / traceLength;
float step2 = FMath::Lerp(hoverForce, 0.0f, alpha);
FVector downwardForce = Hit.ImpactNormal * step2;
//StaticMeshComponent->AddForceAtLocation(FVector(0, 0, 1) * hoverForce *(1.0f - (Hit.Distance / traceLength)), thruster->GetComponentLocation());
compressionRatio = alpha;
surfaceImpactNormal = Hit.ImpactNormal;
surfaceImpactPoint = Hit.ImpactPoint;
The problem is my trace length and debug differs.
If you look at the first picture my trace length is going through the ground. No I don't want that, I want it to touch the ground, and then push me up.
I am in mid - air and my trace length (the yellow lines) are way longer.
] Have I implemented the ray cast wrong?
Feb 11 '16 at 05:29 PM
in C++ Programming