Randomizing a projectile with different classes/objects for fun, ERROR.

So i’m working on a lecture atm spawning projectiles into a scene. I figured it’d be fun to have random objects be the projectile and so I ask a discord community what that would look like. To keep it simple, i went with 2 options, one that would spawn a little less than the other, cool.

This error occurs. Now, perhaps this is beyond my scope but i’d like to see how someone would take this blueprint i’ve made and fix the mesh component issue I have there so I can see what it would look like. I may not be able to fix it myself but for my own learning, i’d like to see what that would look like.

If the blueprint I have isn’t usable for what I was trying to add, then i’d be interested in seeing an entirely new blueprint that shows it correctly working, however i’d like to see the fix added to mine first even if it’s not the “best” way to do it as i’m still new and this is all the lecture has me grasping at the moment. :slight_smile:

(For clarification, before I had the random select node applied, the spawnactor just had a specific class chosen from a drop down and from the “return value” was a “target static mesh component” connected into the target of “impulse” and that’s it.)

Best option would be for the random projectiles to implement a blueprint interface with a function to return the static mesh component from within the blueprint.

Then upon spawning the object call the interface function for example “Get Mesh” and add the impulse to the mesh.

Though projectiles usually are build different in unreal
You usually have a collision class as the root component (can be a sphere collision component) and then a static mesh is added to the collision component and a projectile movement component is finally added to give it movement (non physics based).

1 Like

I’m sadly a visual learner/person so a lot of this is going over my head without actually seeing what it looks like :s
But i thank you for your input!

RandProjectIle.zip (73.5 KB)
Made a quick example project with both physics based projectile and projectile movement.

Fire mechanism is in the player controller.

1 Like

Oh very cool, thank you! I did notice something. They move through each other, i’ll have to check it mine do, but these don’t. Is it easy to make them hit each other and collide and bounce off themselves as well as other objects?

The cube you added also for some reason seems to clip when spawning and doesn’t get the impulse, or seemingly anyway and just hovers and gets stuck in the air. Very strange.

They have their own dedicated collision channel.

It is set to ignore other projectiles because mixing projectile movement and physics can cause them to bump into each other and lose momentum. You can go into the projectile and set collision on for the projectile collision (custom collision class).

Not quite sure why the boxes sometimes stop, I’ll have to add a log to check what they are colliding with.

Edit:
found the cause of the stoppage. Forgot to add ignore to the pawn’s main collision to ignore the projectile (only it’s shape ignored). Added bounce to the cube projectile movement based, returned collision to both projectiles and now they can interact.
RandProjectIle_v2.zip (86.2 KB)

1 Like