ImpactExplosion spawning at wrong location

I posted this in the Q&A but thought it might get more traffic here…

I have setup my Projectile_BP to look exactly like Ben’s in Github. The code is the same as well. But, regardless of where my projectiles hit, the impact explosion is spawned at (0, -50,50) in world coordinates, consistently.

I have tried with/without “use local space” in the particle system. Note also how one of the particle systems shows a full set of transforms, but the other does not. Very weird!..

Found something interesting… I found two ways to get it working, neither of which Ben had to do. I’m using 4.15 so I wonder if that’s part of it…

Option 1:

  • Move the explosion OnHit
  •     impactBlast->SetWorldLocation(muzzleFlash->GetComponentLocation());
    

Option 2 (weird as hell):

  • Do not attach the impactBlast to the root component
  • NO IDEA why this works, but it works consistently. It also enables all sets of transforms for the impactBlast component, not just scale as shown in the picture above.

I actually was having the same problem. Note I am using SetupAttachment to attach the components in projectile.cpp. Your solutions also worked. However the same problem occurred again with the radial impulse, so I started debugging. Short solution, delete all derived content. Add this line to your projectile.h:
#include “Components/StaticMeshComponent.h”

rebuild and it should work.

Long answer:

What I found was an error in the code compilation. I removed all the derived folders. Then tried to launch unreal and it couldn’t build the project, which I have found means there is a compile error. I opened the visual studio project, tried building. It complained a ustaticmeshcomponent couldn’t be a uscenecomponent. I tried including “Components/StaticMeshComponent.h” in the projectile.h, and that cleared that up as well as SetupAttachment working properly.

Just thought I’d post this because it was a weird bug, hope it helps someone and when in doubt, delete all derived content and rebuild :slight_smile:

Privacy & Terms