Hello,
In the past I have attempted to make a hover car/ physics car with suspension mechanics in blue print and half managed to meet my solution.
I am not a visual scripter, since I come from a Unity/ As3 background.
In an attempt to line trace down via c++ UE4 library, I have first added four points to a static mesh.
These for points are added via code, and in the blue print I move them manually.
In my script I add all of these four points into an array.
TArray<USceneComponent*> hoverArray;
t1->AttachTo(StaticMeshComponent);
t2->AttachTo(StaticMeshComponent);
t3->AttachTo(StaticMeshComponent);
t4->AttachTo(StaticMeshComponent);
hoverArray.Add(t1);
hoverArray.Add(t2);
hoverArray.Add(t3);
hoverArray.Add(t4);
I then loop through the array and do a line trace to see if I am hitting 40 yards down.
for (int32 b = 0; b < hoverArray.Num(); b++)
{
const FName TraceTag("MyTraceTag");
FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
RV_TraceParams.bTraceComplex = true;
RV_TraceParams.bTraceAsyncScene = true;
RV_TraceParams.bReturnPhysicalMaterial = false;
RV_TraceParams.TraceTag = TraceTag;
//Re-initialize hit info
FHitResult RV_Hit(ForceInit);
FVector Start;// = FVector::ZeroVector;
FVector End;// = FVector::ZeroVector;
FVector GetUpVector = FVector::ZeroVector;
Start = hoverArray**->GetComponentLocation();
GetUpVector = hoverArray**->GetUpVector();
GetUpVector = GetUpVector*(traceLength * -1);
End = Start + GetUpVector;
//End = hoverArray**->GetWorld + (hoverArray**->GetUpVector()*(traceLength*-1));
//call GetWorld() from within an actor extending class
GetWorld()->LineTraceSingle(
RV_Hit, //result
Start, //start
End, //end
ECC_Pawn, //collision channel
RV_TraceParams
);
RV_Hit.bBlockingHit; //did hit something? (bool)
RV_Hit.GetActor(); //the hit actor if there is one
RV_Hit.ImpactPoint; //FVector
RV_Hit.ImpactNormal; //FVector
RV_Hit.Time;
DrawDebugLine(
GetWorld(),
Start,
RV_Hit.Location,
FColor(255, 0, 0),
false, -1, 0,
12.333
);
}
I’m guessing the problem is in the “End” Variable.
This is the result…
Can someone please tell me why the “End” point is not updating?