• News

• Industries

• Learning & Support

• Community

• Marketplace

Trying to make a pick-up "pop" out when spawned, Mario style.

SO, I am able to spawn pick-ups that have a physics simulation attached.

I am also able to pick them up.

What I am trying to do now is to get them to “pop” out when they are spawned.

Ultimately, they would each pop out at a slightly random arc, and height from each other. Imagine the coins from a Mario game, popping out of a block.

I assumed I would apply a “pulse” to them to get this to happen, but cannot seem to figure it out.

ALSO, hopefully this is something that can be applied on the PICK-UP BP, so I don’t have to manually apply this to every pick-up that I spawn in the LEVEL BP.

Any help here would be greatly appreciated.

Are you trying to spawn a coin coming out of a block in the same manner every time then disappear after a set amount of time?

Basically.

Imagine if you had a treasure chest that opened. When it opens, the treasure randomly pops out of the chest and lands on the ground, waiting to be picked up.

The part I am trying to figure out is the randomly popping out part.

Oh, well if you have physics enabled on the object and it has a collision mesh, you can simply use the “Add force” node and plug in random ranges for your vector values. Obviously you’d want to keep your Z postive and X and Y can be dependent on any number of factors, like the box’s location/proximity to other objects or your character’s position/rotation. Does that make sense? I feel like I’m rambling, heh.

Makes perfect sense! Totally works. Thank you!

My problem was, I needed to set pretty high numbers in the “Add force” node to see anything happen. In the realm of 100,000.

Now to tackle the random vector values. Thank you again.

Haha, yeah. You would think something like 1000 would be enough, especially if you come from Unity (like me). But you have to remember that Unreal works in centimeters, so you have to multiply anything you’d use in Unity by 100. Makes sense, but still trips me up sometimes.

I’m really glad it works for you! If you need help with figuring out your randoms, let me know!

Going to take you up on your offer!

So, I have them “popping” now, but they pop to the same location every time, as the force in the X, Y, and Z is not random.

I know I want them to pop roughly the same height, but want them to randomly land in a 360 degrees area around the spawn point. Does that make sense?

Sure. Spawn a Random Float in Range “0-360”; Make Rot with that as a Yaw value, get the forward vector of that rot, and then scale that vector by a float of 25,000 or whatever you’ve decided on for the force (you could probably also use a Random Float in Range here and do like, 20k-35k so that how far it launches changes a bit each time). Then use a Vector + Vector node to add a vector of 0,0,150k or whatever you want the constant Z value to be, and connect it to the Add Force input.

You can also limit that float range a little bit (e.g. -90 to 90 rather than 0-360) if, say, you only want the item to pop out FORWARD from the chest.