Search code examples
unreal-engine4

UE4 Shoot Projectile BluePrint - Projectile spawns but doesn't move


I am trying to shoot different projectiles based on which weapon is currently selected. The projectiles spawn but don't move anywhere. I currently have 2 projectile BluePrints (Parent and child):

BP_Projectile (Parent)
BP_PistolBullet (Child)

The parent class has a float called ProjectileSpeed. I have set the value of the float in the child class to 5000.0 for testing.

For the moment the child class contains a Cylinder with a box collision just so I can see something render. I have enabled 'Simulate Physics' on the cylinder.

I have then created an array called CollectedWeapons in my character blueprint with a type of BP_Projectile and added a single element with the value set to the class of BP_PistolBullet (I know a projectile isn't a weapon, but thats going to be expanded later :P ) CollectedWeapons Array

The rest can be seen in my 'Shoot' BluePrint: enter image description here

If you need any more information please let me know. Thanks in advance.

EDIT:

BP_PistolBullet components as requested.

BP_PistolBullet Components

EDIT:

Trying to make projectile shoot forward, but can't get it right. I've tried multiple different things, but this is the latest attempt: enter image description here


Solution

  • It happens because you tring to access Cylinder Static Mesh component by using "Get Child Component" node. "Get Child Component" returns one component from set of directly attached components. When you enable physics simulation on component it is automaticly detached from it's parent component, so it could behave independently. It leads to situation when simulated components are not present in results of "Get Child Component" of your "Default Scene Root".

    You could solve it quickly by saving physicaly simulated child component to some variable present in BaseProjectile. But I think perfect design will be to use "Projectile Movement Component" in base blueprint or to apply force directly in blueprint in "BeginPlay" event.