Are there any updates in regards to custom gravity of arbitrary directions?

A year ago, there’s a discussion about custom gravity vectors here.

One of the staffs mentioned that custom gravity for users to modify on actors is something they were looking into.

Is there an update to this? Can custom gravity be set for all physics actors?

Hello

After doing a bit of digging I was able to find the report (UE-2082) that was written up for this request. This issue has not been resolved yet. However, I will be sure to bump up the community interest. I hope this information helps.

Make it a great day

This was one of the few reasons why I had to drop development on a very asymmetrical VR experience.

I’m looking at adding this myself on the current 4.8 master. Right now there are a whole bunch of assumptions about GravityZ, including legacy ini stuff. If I have anything useful. I post here.

Tommy.

Yeah… I can see why this hasn’t been done yet. The implementation for gravity is pretty messy. While a gravity vector is passed to PhysX, the vector is not a true direction. Gravity is instead constrained to the Z component only, as “GravityZ”, which is -980 by default, is set on this vector for the Z component. This seems like a legacy issue, but basically changing this to a a proper FVector would be trivial, and therefore give you abitrary gravity direction for physics objects, if it wasn’t for:

  • UMovement
  • UCharacterMovement
  • UProjectileMovement

Which all have hacks based around the Z being the only axis on which gravity moves. For the ProjectileComponent, for example, there is some code to calculate a ballistic trajectory based on the Z axis… this is definitely more involved then just a vector direction.

Tommy.

Right… I’ve gotten arbitrary gravity direction working quite easily except in several places (mentioned in the post above). If people are interested, I could try cleaning it up and creating a PR for the master branch, however it would NOT function for any character based movement, which would still operate with respect to Z. You would need to write your own character movement controller to support the arbitrary gravity vector.

Tommy.