How do i create a projectile using a SkeletalMesh?

Hello, i’m trying to create a projectile with just a skeletal mesh and a projectile movement class. I set the constructor like this:

Mesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Mesh"));

	RootComponent = Mesh;

	ProjectileMovement = PCIP.CreateDefaultSubobject<UProjectileMovementComponent>(this, TEXT("Projectile Movement"));
	ProjectileMovement->UpdatedComponent = Mesh;
	ProjectileMovement->InitialSpeed = 6000.f;
	ProjectileMovement->MaxSpeed = 6000.f;
	ProjectileMovement->bRotationFollowsVelocity = true;

The projectil is being fired but the skeletal mesh is not colliding with anything. I have a physics asset configured for the skeletal mesh i’m using, shouldn’t it use that for collision checking?

P.S: What is the best way to detect the hit? OnProjectileStop.AddDynamic or some other event?

Does your skeletal mesh have a physics asset?

Are you setting the collision of the skeletal mesh in the editor or are you doing it all in code?


Hello Rama :slight_smile: yes my skeletal mesh has a physics asset. The collision is set on the constructor (i forgot to put it on the code) where i assign a projectile collision profile that blocks everything if im not mistaken. I confirmed on the blueprint that derive from that class that the collision profile is active.

I am not sure why this is not working, perhaps the movement component is having trouble relating to the physics asset as the source of collision.

Cant you wrap the skeletal mesh with a simple sphere,or box collision, or several such simple collisions that you arrange in the editor to essentially match what the physics asset is doing?

The setup you describe sounds good

I assume you’ve verified that the skeletal mesh in its current state does collide with the ground and such if you turn physics simulation on?

Maybe try the simple collision primitive wrapper idea and at least get it working to narrow down the issue

I created a new blueprint with just the skeletal mesh and simulated physics with collision as BlockAll and it fell to the floor and collided properly, so the skeletal mesh is fine. I added a BoxComponent to the projectile like you suggested and set it up as the UpdateComponent of the Projectile Movement Component and it’s working fine, so i guess the physics assets might be too heavy operation to do on fast moving objects, but i would like to have an confirmation from Epic about this, just to make sure if there is no other way.