Repulsive forces by expanding AlignPosition and VectorForce

As a Roblox developer, it is currently too hard to create repulsive magnetic fields or any other kind of repulsive force due to the lack of fitting physics constraint behavior. The only two potential objects currently available are AlignPosition and VectorForce, but both are lacking in functionality to allow average developers to create a repulsive force on his/her own:

VectorForce lacks a suitable RelativeTo option to create the desired effect:

  • Enum.ActuatorRelativeTo.World is far from ideal when dealing with a repulsive force between two moving objects. You would need a continuous loop which checks the object their positions and distances to constantly recalculate and apply the right force. Additionally, many developers do not have the right physics knowledge to figure out what the correct calculations would be for repulsive forces.
  • Enum.ActuatorRelativeTo.Attachment0 and Enum.ActuatorRelativeTo.Attachment1 have the same issue as above, except that now the axis can move as well, making it an even worse option.

AlignPosition currently only allows two attachments to move closer to each other. There is no property or method which allows a negative force to be applied instead of a positive force. Because of that, the AlignPosition constraint cannot be used to create a repulsive force.

If Roblox is able to address this issue and were to implement a way for developers to easily create repulsive forces, it would allow us to create many cool new gameplay features:

  • Magnets which can be used to pull and push platforms, opening up more platforming possibilities.
  • A wind blower tool which will blow away small objects in front of the player (or even other players!). This could be useful for minigame places or roleplaying games.
  • Explosions that cause debris and other assets to fly away from the point of impact.

In my opinion, the best implementation for my requested feature would be to add the following, but it’s of course up to the engineers to make the final decision:

  1. A property in the AlignPosition object to toggle whether the applied force is positive (current behavior) or negative. That way developers can simply toggle a boolean to apply the desired behavior.
  2. A new enum Enum.ActuatorRelativeTo.Direction which can be set in the VectorForce.RelativeTo property. Developers will be able to set an Attachment0 and Attachment1 and the resulting direction from Attachment0 to Attachment1 will be used as the applied force’s direction.

If anyone has any other use cases for the requested feature, feel free to post them!



LineForce.Magnitude = -1000

actually repulses.

If you do,

LineForce.ApplyAtCenterOfMass = true
LineForce.InverseSquareLaw = true

with two same mass objects, that would actually make repulsion force exactly like of two electrons.


That actually works…

I’m not really sure what to think about that solution since it sounds really hacky to me. I never would have never expected that applying a negative magnitude would be possible since to me it sounds like - by definition - a magnitude has to be positive. Anyways, thanks for providing an alternative. I’ll still keep this topic open though because I believe my request would be a better solution.

1 Like