Dynamic gravity for characters

Hi. Do I still need to download the project from github? How do I get my hands on good stuff?

Beta 5 is up with fixes for UE 4.13.1, check the first post for more details.

@: First of all, thank you so much for very generous contribution, I sincerely hope that will get integrated into the engine.

I am no newb at all here, but I can’t seem to figure out the API for thing. When I use UNinjaCharacterMovementComponent->SetGravityDirection(FVector(0.f, 0.f, 1.f)), my character just floats to the ceiling with no rotation, same as if I was to directly change the GravityScale float.

What am I missing here?
Once I figure out, I’ll be happy to help with a tutorial for newcomers to your plugin, if it has any interest.

EDIT: What I was missing was the public settings on the UNinjaMovementComponent, specifically the flag “bAlignComponentToGravity”. Makes total sense. Don’t mind me :slight_smile:

No problem mrzapp, I released something with no documentation after all, it’s better to ask here so that other people have the to not miss the solutions. Thank you.

@I’ve been following your work. I’m looking for a bit more info on the player controller orientation. When I use the Add Controller Pitch Input, the controller seems to only be aligned to the world and not my character (a spaceship). Does your code address that part? I don’t really need the arbitrary gravity, but I do need to figure out a way to get around the controller’s pitch being relative to the world and not the character. I’ve also seen the Arbitrary Orientation thing on Trello (backlogged to 2017). Is that supposed to fix the controller pitch being relative to the world? I appreciate any insight! It’s kind of blocking my progress right now. Thanks!

HI!

I’ve been working with your code but at the time I tested it with dedicated server and two clients, the Simulated Proxy didn’t align to the surface. Is thath a know in your code? or maybe I broke something? If not any idea how can I replicate to a simulated proxy the character orientation?

Just want to inform that I couldn’t build in 4.14 and the error I get is that it tries to find “\Epic Games\4.14\Engine\Source\Runtime\Engine\Public\Net\PerfCountersHelpers.h” which is actually located “\Epic Games\4.14\Engine\Source\Runtime\PerfCounters\Public\PerfCountersHelpers.h”

So, I did everything, but I dont know hot to compile game project after adding “AIModule” to build.cs.

Thank you!

For compiling the game you have to open with visual studio (or simply by dobule clicking) the .sln file that is on the root folder of your project, then u will see all the project files like on my image and u can compile it, the steps i followed where opening the solution with the .sln file and then modify all the needed archives that the readme tells to you and then go to compile, compile solution.

Oq7X8m1.png

Did you ever get figured out? I need dynamically oriented cameras for my first person project as well.

Unfortunately no. I stopped working on that project shortly after comment and it’s been a long while. I did find out where you can do it, but the solution escaped me at that moment so I fiddled with other stuff and just toggled pitch and yaw limits off allowing 360 free camera movement to test the game.

I’m not sure what kind of project you are working on, but in your playercameramanager class (I reckon you would be using one) there is a function called ProcessViewRotation with which you can use to limit your yaw and pitch according to calculations or rigid values. I think I tried it with getting player rotation in world space and calculating max yaw and pitch from that but it worked poorly. Not sure anymore though… The documentation for it is here ProcessViewRotation(). It returns a boolean based on your limit values and in the normal workflow that tells your camera if the view is updated or not by your mouse movements/whatever… Due to the complex nature of my game and constant calculations I tried in function, I think it failed to produce my needs because it is only a boolean and doesn’t actually adjust the camera if the camera goes over the limits -> if you jump over your threshold your camera just gets stuck so you need to realign it in another function.

Hey, why is all of source code down? Is there anyway you can share?

I couldn’t get to work. Can I get some help?
I followed the steps and promoted the character to a blueprint character and I cant even move. I made sure that the axis mapping was the same as on the code.

Hi all. Just wondering, are there still plans to eventually integrate into the engine? (And will ever be accessible 100% through blueprints?)

Thanks!

Hello @just wondering if you had experimented or came across any solutions for navigation and ai was thinking on the custom geometry that has the gravity class of covering with hexagons and then using each as a flat plane to NavMesh over but navmesh only works in z up so thats out and seems exhaustive or if even possible. The other is a custom path finding using A* for the surface of the sphere but id have to look into that and would not have a clue where to start so basically looking to see if any one else has any ideas?

TLDR:
AI on single sphere only think meteor more than world

would work for creating gravity for planets(spheres)?

Has anyone set up in UE4.15? thats what im trying to use but visual studio is bringing up 9 errors and 2 warnings.

Errors/Warnings:

Severity Code Description Project File Line Suppression State
Error C2027 use of undefined type ‘UDamageType’ CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 41

Severity Code Description Project File Line Suppression State
Error C2227 left of ‘->DamageImpulse’ must point to class/struct/union/generic type CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 41

Severity Code Description Project File Line Suppression State
Error C2789 ‘ImpulseScale’: an object of const-qualified type must be initialized CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 41

Severity Code Description Project File Line Suppression State
Warning C4458 declaration of ‘CharacterMovement’ hides class member CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 43

Severity Code Description Project File Line Suppression State
Error C2027 use of undefined type ‘UDamageType’ CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 51

Severity Code Description Project File Line Suppression State
Error C2227 left of ‘->bScaleMomentumByMass’ must point to class/struct/union/generic type CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 51

Severity Code Description Project File Line Suppression State
Error C2789 ‘bMassIndependentImpulse’: an object of const-qualified type must be initialized CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 51

Severity Code Description Project File Line Suppression State
Warning C4458 declaration of ‘CharacterMovement’ hides class member CodeGravity D:\Projects\Unreal Projects\CodeGravity\Source\CodeGravity\NinjaCharacter.cpp 108

Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: ‘PerfCountersModule.h’: No such file or directory CodeGravity D:\Epic Games\UE_4.15\Engine\Source\Runtime\Engine\Public\Net\PerfCountersHelpers.h 9

Severity Code Description Project File Line Suppression State
Error Failed to produce item: D:\Projects\Unreal Projects\CodeGravity\Binaries\Win64\UE4Editor-CodeGravity.pdb CodeGravity D:\Projects\Unreal Projects\CodeGravity\Intermediate\ProjectFiles\ERROR 1

Severity Code Description Project File Line Suppression State
Error MSB3075 The command ““D:\Epic Games\UE_4.15\Engine\Build\BatchFiles\Build.bat” CodeGravityEditor Win64 Development “D:\Projects\Unreal Projects\CodeGravity\CodeGravity.uproject” -waitmutex” exited with code 5. Please verify that you have sufficient rights to run command. CodeGravity C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets 41

I got it working in 4.14, to solve you just need to add “PerfCounters” to your .Build.cs file:


PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore","AIModule","PerfCounters"});

So I got working but I was wondering how I could implement a first person view with a standard camera.

When I reach an almost upside down state, the camera does not rotate it’s ‘floor position’ with the character resulting in crazy flippyness.

How would I make it so that the cameras base rotation is rotated with the character’s rotation on a surface and is that the right way to look at it?

Is a that is going to be integrated into UE4? I can see a lot of use for something like .

Can AI controlled pawns navigate around shapes as well?