Is there a force that pulls from one side and pushes on the other?

So I’m creating a space game and I need to know of there is a way to apply force to create a vacuum effect. For example, if there is a hull breach I want to create a zone that will suck objects that are inside a certain area and eject them through the breach.

The image below shows a simple example of what I’m looking for.

Basically any objects inside the yellow semi ciral will get pulled towards the breach and then jettisoned into space.

I thought about using a radial force but that will only push or pull not both as far as I know. Other ideas I had would involve creating an object at the location of the breach and all objects near it would move towards it then once they collided with it I will add force in the proper direction. The only problem with that is that the suction isn’t based on physics and could cause unrealistic effects on players.

So basically I’m asking, is there a way to achieve this effect?

I forgot to mention the game will be top down and only need movement on the X and Y axis.

Thanks you,

Try something like this:

Create an Actor with a spherical collision component.

Create a function on it called Suck using blueprint.
In the Suck function, get all the actors which overlap the sphere component.

Calculate the direction for the suction force for each object by subtracting the object’s world space position from the world location of the Actor you are making - this will give you a direction vector in world space.

Normalise the vector, so that it represents a force of 1 unit towards the suction Actor.

Multiply the result by however strong you want your force to be and then use Add Force on the object you want sucked out to start it being pulled towards your breach.

That could work but instead of a spherical collision I would need to make a custom mesh or use a cone to avoid objects getting sucked back into the ship.

Thanks for the response. I will let you know how it works when I test it.

You would only have that problem if there were objects already outside the ship. I’m talking about checking for overlapping objects once, when you enable the system, not triggering on an overlap event. This means that objects inside the ship will be given a force pushing them towards the epicentre of the suction actor, and that force will keep them going in the same direction when they leave the ship - when they get to the second half of the sphere they won’t have the force added again, so theres no chance of them being pulled back towards the ship on the outside. If you have debris or something outside the ship already when this happens, then yes you are correct about using a custom collision mesh.

Well to be honest the force stops once pressure is equalised between the two spaces, so you’d only have this issue if you kept on pumping air into the room with the breach, and once the initial explosive decompression occurred it would likely be a much weaker, perhaps even negligible force. So I dont think it should affect items that enter the room after the breach happens.

There will be multiple rooms inside my ship and each can be sealed off. Now if you only check once for objects in the room then apply the force, what happens if an object enters the room after the check? Still a great answer and I was given an idea of how to solve my problem.

That is a fair point.