UE5 is there a simple way to override gravity in a volume

I’m simply wondering if there is a way to create a volume where this gravity override takes effect, here are two examples I had in mind.

In a Cube, the gravity would change direction, this could point in any direction.

In a Sphere the gravity would pull everything to the center of the volume.

And if something leaves the volume that gravity will resume as it normally would.

I would prefer if this volume could be freely moved around, like for example if it were attached to the character or a projectile, and would like to avoid any method that would make it static.

I would also like to know if there is a way to make specific things immune to these gravity overrides and have them only affected by the normal gravity.

2 Likes

See if you can work with something along the lines of:

  • an actor with a collision volume detecting components that overlap it
  • if the entering comp has an appropriate tag and simulates physics, we add it to an array
  • when comps leave volume, we remove them from the array
  • the actor applies force to all components that meet the abovementioned criteria

The spheres are unaffected here as they do not have the tag - that’d be one way to exclude things.

In a Cube, the gravity would change direction, this could point in any direction.

You could use the same method and:

Rather than towards the centre.

attached to the character or a projectile

Sure, why not:


This can be improved in a number of ways:

  • linear and angular dampening could help
  • force diminishing with distance for spherical volumes would make it seem more natural, surely

And there’s probably some kinks to iron out, as always. You’d also need to work a bit harder to get it affect player’s movement component.

Perhaps this can get you going, though.

Good luck!

2 Likes

I’ve only been on the forums a few times before, but I’ve seen you around quite a few times, you are most certainly a hero. I’ll be looking into this, I’ll also need to brush up on what arrays are since I’m still quite new to Unreal Engine, but this is going to be so fun to mess around with!

Thanks!
**

1 Like

Oh yeah, I keep forgetting this little thing exists:

Comes with Types list, Force can be negative - may be worth playing with.