Thanks! That’s a great resource. But unfortunately I need a more holistic solution. The one you linked (as well as various others) usually only apply to a custom character movement component and an actor. I need the custom gravity to apply to everything in the world, globally. Thankfully, I downloaded the UE4 source code the other night and I’m already well on my way to implementing such a solution.
After looking at the source code I think it’s hilarious that global gravity comes down to an FVector setup like this:
Had it been setup like this:
And exposed to blueprints (so that It could be changed in real time, which I’m currently in the process of doing) then this whole thread and countless others would be void.
I will see what I can do, although I assume that people before me have investigated the same thing and pushed the changes to EPIC only to be ignored.
Moreover, my solution would not be a plugin. It would involve users compiling UE4 from source which may put many people off.
Although I will post the code to my own Github repo!
However I’ve run into another issue on my PC that until it is fixed, I cannot continue my work:
there is a custom gravity plugin that was free couldn’t you open it up and see how they did it? they made gravity for objects like spheres etc. I have no clue why you would want to change a gravity direction when you can use physics forces and all that.
physics forces don’t work the same as gravity direction or the effect of zero gravity in UE4. I already did look at the plug-in you mentioned and here is how it works:
The creator has made a custom pawn class that contains a custom movement component in which it has a gravity system independent from what ever UE4 is doing globally.
The problem with that plugin is that anything you want to make have gravity direction must be a “custom pawn” including simple objects such as traffic cones or crates. They all must be “pawns” in this system. This problem becomes worse when you realize that it is useless when it comes to vehicles. As vehicles in UE4 cannot be inherited from this custom pawn class.
Did you tryed : Create an actorComponent that add force to the rootcomponent of the actor (disable gravity), Get the gravity from a c++ static FVector like this you can change it for the whole world. I have no idea about performance compare to the ue4 gravity system.
This should all be considered when the change from PhysX to Chaos is fully implemented. It’s obviously something people want from the engine, it’s a limitation that only has reasoning on the implementation level so can be completely avoided with a refactor, and let’s face it, this is only ever a relative sim-gravity as a sweep across the board anyway. It’s not real gravity so why not improve on it whilst the option is there? The physics code potential from real world to game level has definitely stepped up over the past couple of years to facilitate it.
Yes I’ve already tried this. Vehicles physics in UE4 are calculated using approximations and “forces”. The wheels on the car don’t actually spin. Therefore, “pressing” the car to the ground (or any surface) doesn’t behave as it would in real-life. This causes the car to not move because the speed of the vehicle is dependant on gravity approximations that are hard-coded into the Engine.
There is much more going on “under the hood” that I can’t summarise in a short comment, but to answer your question; Yes I’ve tried it, and no it doesn’t work unfortunately.
This sentence right here is one of the reasons why I started this thread. With games like Star Citizen (and many other space games such as Star Wars) having multi-planet gravity systems and local gravity on space-ships is only going to be more standard among games as the industry moves forward. For epic to not even acknowledge such a “simple” feature is a complete misstep on their part.
I looked at the latest UE4.24 and saw nothing has changed when it comes to the gravity system. So it doesn’t even look like such a feature is “in the pipe line” unless I’ve missed some something.
No problem, that plugin was one of the first things I checked out because I was so curious how they managed to pull it off. But so far in my search for a “real-solution” it seems that no code or plugin on the market actually attempts to fix the core issue of the engine. They are all just selling “hacky” ways to dance around the issue each with their own set of limitations.
Vehicles are piped through PhysX, it’s not a native implementation and barely anything to do with UE4 to be honest. PhysX is pretty much the staple physics engine for a huge quantity of games. All game physics engines are approximations and inaccurate.
I’d also strongly argue that games like Star Citizen are in no way mainstream or even common, and a multi-planetary gravity feature - or even changing the gravity direction at all, is extremely game specific. Non-fixed gravity directions in character movement means more netcode, at the very least more complexity. Most games have fixed gravity, and the last thing CMC needs is more complexity to satisfy a handful of games that would use this feature at the expense of all it’s users.
I agree! But there are plenty of games that use manipulation of gravity as a game-mechanic such as: Star Citizen, No Mans Sky, Prey etc… Just because Star Citizen *specifically *is not mainstream (partly because it isn’t done *and *the developers are managing the game poorly imo) does that mean we shouldn’t expect such a feature? or even ask for it?
As for my quote about this:
I worded it poorly, what I mean’t is that having gravity direction *as a feature *is only going to get more popular as the industry moves forward in all genres such as puzzle games, sci-fi etc… I didn’t necessarily mean that space games are going to get more popular.
I’m unconvinced that this will be a dramatic set-back. Technically if the new code is a single line longer, your statement remains to be true. But is it fair to bring it up as an argument against such a feature? By how much is “more netcode”? Also, even if there is *“tons more netcode” *(and that’s pushing it) couldn’t such a feature simply remain as single-player only? I’d rather have the feature only work for certain types of games, than not there at all.
I’m not going to address this last statement because it seems more like an opinion piece than an actual technical statement backed by evidence. How can I even begin to respond to this when you say things like “at the expense of all it’s users”. Most of UE4’s users are hobbyists that aren’t squeezing every last drop of performance out of CMC. The professional developers that are, can simply create a separate class with stripped back/simplified code.
I agree with your overall sentiment on the basis that:
adding such a feature would be a significant detrimental cost to both epic games’ employees (pulling them away from more important features) as well as the UE4 community (with the negative performance impact on machines).
But I have yet to see any evidence that that will be the case.
Thanks! I’m checking out the link. It seems like this might just solve my problem. When I added force to vehicles using the blueprint node “Add force”, this had undesired affects. I’m hoping that adding force using the code:
Will produce the desired results.
EDIT: I’ve just implemented the code and it had the same undesired affects as the blueprint “add force” node… aka, the vehicle doesn’t move when “pressed to the ground”. The struggle continues.
Yes and no, I got direction gravity to work in real-time but it affects ALL objects in the world that use gravity (including player/vehicles). But I never could figure out how to change the gravity on a per object basis. It IS possible, I just never found/figured out which class actually ‘sets’ or ‘gets’ the gravity on an individual level. I will eventually take another crack at it in a month or so when I get free time. Hope this helps. However, the best solution would be one from epic themselves. So message the staff or put a feature request in if you need the feature sooner.
Would mind running through how you did this? I’m making a multiplayer planet based game and need to fix the gravity of to the center of the planet (directional gravity). I’m happy to build the engine from source to do so, would you mind detailing exactly what you do to get this working?