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?
!! I need all of those. Almost all of my ideas for games would be greatly accelerated with vector, point, or cylindrical gravity. Even a pinball game would be much easier to layout if I could use vector instead of the limiting -Z.
I’m willing to help advise and test/debug for this - I have some experience with PhysX, though I haven’t tried messing with the gravity much, as it didn’t have the capability to set a per-frame gravity vector when I was using it at a low level.
This would be perfect for a project a few friends and I are working on. Being able to create a gravity effect in any direction by specifying an angle or a vector would be such an improvement.
You could achieve so much with this! I’ve been trawling the Web trying to find someone who’s achieved this and found one thread where they had gravity working in both the x and z axis for the player, particles and world objects but they didn’t leave any documentation or source code (copywrite reasons?) either way, this would be epic if you could pull it off.
Intergration in physics volumes is a must. I’m all for it, I really hope this happens!
It’s easy enough to do currently, but built in support out of the box would be nice.
The thing is, you’ll be working with PhysX, not the engine. I don’t think there’s anything in the Engine that specifically prevents other gravity types, but PhysX itself might not have support either, so you’ll have to go deep into nVidia code to do a lot of this too.
last time i looked at this, if i remember correctly, physx expects a vector. it is somewhere fairly early on in the engine code it changes from a vector to a float.
could be wrong but thats how it looked to me.
would definitely be a lot of work as gravityZ is everywhere but absolutely worth doing.