Add Impulse to spawned actor class from array
So inside of the Level Blueprint I'm using an array of actor classes and feeding that into a spawn actor. The idea is to pick a random actor, give it a random position within a set volume as well as a random rotation and scale. Then after the actor is spawned, give it a random Impulse (or Linear Velocity) to get the things to move. Gravity is currently set very low so everything floats.
Problem is... AddImpulse and SetPhysicsLinearVelocity both require a Primitive Component target which the Spawn Actor does not give. If I disconnect the Class array and set the actor manually (to a Cube in this case) then Unreal automatically converts the target to a Static Mesh and then to a Primitive Component.
But whenever the array is plugged back in, the target no longer carries over.
Only way I could think of to get this to work would be to add a GetRootComponent, plug it into a Cast To PrimitiveComponent and then do AddImpulse but the Cast continually fails. And I'm not even sure that's the best way to do it, TBH.
Anyone have any ideas on how to get the PrimitiveComponent of a randomly spawned Actor class?
asked Feb 08 '17 at 08:47 PM in Blueprint Scripting
You can select the first found primitive component like this, cool.
answered Feb 09 '17 at 07:40 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here