How to make a "Directional Force Actor" with Bound-Mesh

Hi guys,

This is what I’m trying to achieve: I want a mesh (a sphere at the moment) that overlaps with anything and applies a force onto that anything, that has always the same direction. The magnitude should be determined by where that something is in the sphere (right now I would simply scale the force with the X coordinate). I thought that I would be able to get that data like this (supposing there is only one component overlapping with my sphere, I would of course check for this normally):

sphere->GetOverlapInfos()[0].OverlapInfo

This returns a FHitResult. I don’t know that class very well, but there are a couple of vectors in it, so I thought I’d figure it out. However: They are all (0,0,0), always. Is this a bug? Everything besides Time (= 1.0), Item (= -1) Actor and Component (which are correct) seems to be defaulted to 0 (or equivalent) in the FHitResult.

I had a strange occurence while debugging (optimized) code, that the vector I assign the ImpactNormal to would contain a sensible value BEFORE I assign the ImpactNormal to it. It would have correspondet to the overlap location in World Space (I think, might be wrong here). Debugging the same bit of code with “DebugGame Editor” settings however does not yield that. I think I might just have been “lucky” and my variable occupied the same storage as a vector before it. Because if that was not the case, then the OverlapInfo I inspected would also have to be “wrong” and I think that’s highly unlikely.

Now: I am doing this right? What I effectively want is some coordinate that is the point of overlapping. I am aware that this by itsself is not really a thing, since the meshes do not overlap in one point, but in a whole volume, so I don’t even exactly now what point I’m looking for. I hoped as I looked at the datastructures I would understand the approach the engine takes to such a representation.

I hope one of you can help me here,

And as usual the answer comes to me, as soon as I clutter the forums with my question :D. The problem was that HitResult was not generated by a sweep, as bFromSweep told me, but I didn’t know that this was important. However, it is clearly documented, that in this case only some members are valid. To get around this, I used the workaround suggested in this post. The code looks like this in the end:

for (FOverlapInfo var : info){
    TArray<FHitResult> results;
    FVector start = GetComponentLocation();
    FVector end = var.OverlapInfo.Component->GetComponentLocation();
    float collisionRadius = FVector::Dist(start, end);
    GetWorld()->SweepMultiByObjectType(results, start, end, FQuat::Identity, 0, CollisionShape::MakeSphere(collisionRadius), FCollisionQueryParams(false));
    for (FHitResult hit : results) {
       if (hit.Component != var.OverlapInfo.Component)
	       continue;
       else{
           DO ALL THE STUFF

A bit ugly but it woks. I will now do all the figuring-out-vector-bits that I wanted to do anyways, so I haven’t created a “Directional Force Actor” yet, but I’m on my way now.