I have an open pull request to modify gravity within a Physics Volume. It is #376: “Character and Projectile Gravity Override in Physics Volume”.
Currently, most people use Blueprints to accomplish its goal by keeping track of actors which enter and exit the Physics Volume. This pull request moves that functionality to properties of the volume, itself. It can add gravity, multiply gravity, or replace gravity with a specific value, positive or negative. It does not work on PhysX or Box2D objects, though. This would require some significant changes to the physics engine because it, currently, applies a single gravity value for the scene (although it allows the value to be modified on a per-frame basis).
Also, when discussing it in the IRC, people seemed a bit disappointed that it only worked on Z gravity. Apparently, some people want non-Z gravity.
Given that Unreal Engine 4 is a community project, I wonder how many people would be interested to, and participate in an, overhaul (of) the physics interface, altogether. This would obviously require significant community effort, especially if we want to make it backwards-compatible with existing projects (and we obviously do).
I had a couple of ideas:
- For backward-compatible gravity overrides: Give each object a flag to override gravity. Also, give the scene a flag for “Custom Gravity” – which passes a zero-vector to PhysX’s default gravity and gives each object a gravity property.
- For backward-compatible non-vertical gravity: Add a second parameter to gravity – a normalized vector for direction. By default, this would be (0, 0, 1) so that a magnitude of -980 would result in a gravity of (0, 0, -980), as expected.
- With both, above points: The “normalized vector” for gravity could also accept an actor (or provide an actor to be placed) which will point to the physics object (as a means of driving the normalized gravity direction vector). Example: A point at the center of a large sphere drives a normalized vector from it to the physics object for radial gravity.
Of course, this will result in a large rewrite of CharacterMovement, the PhysX and Box2D wrapper, and so forth.
- Would it be helpful to serious projects? Are there any, serious projects that would like this?
- Also – can you think of any better methods or list potential (/definite) consequences?
- Also – does this not go far enough? Is this too limited for the needs of your project? What are those needs?
Thoughts? Concerns? Comments?