Dynamic gravity for characters

I figured it out, thanks.

Now I see a confusing amount of files in that folder… I guess I have to find a tutorial for making something with .

i need help plz

i want to have a planet and my character can run on it how do i do that with ninja

thx

how do I recompile engine code?

I’m trying to compile on 4.12.5 and my project has no Xs.h/XS_API files.

I’m trying to compile on 4.12.5 and my project has no Xs.h/XS_API files.
[/QUOTE]

Hello!
Check README.txt in the zip file :slight_smile:

****, why you shared your project via mediafire.com, with NinjaCharacterBeta4.zip file, but not with another one git repository at GitHub? :slight_smile:

I created a new C++ FPS project in Unreal Engine v. 4.12.5, and called it “Xs” for the sake of simplicity.
I Created the C++ classes in the Engine, and then(since the project was called “Xs”) I simply copied the code from the *.h and *.cpp files included in the NinjaCharacterBeta4.zip to the newly created *.h and *.cpp files in Visual Studio.
I added the extra dependency line in the Xs.Build file, and tried to compile with Visual Studio Community 2015, but I got :



C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(988): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(988): error C2227: left of '->bWaterVolume' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(998): error C2065: 'UBrushComponent': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(998): error C2065: 'VolumeBrushComp': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(998): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(998): error C2227: left of '->GetBrushComponent' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1000): error C2065: 'VolumeBrushComp': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1007): error C2065: 'VolumeBrushComp': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1007): error C2227: left of '->LineTraceComponent' must point to class/struct/union/generic type
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1007): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1083): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1083): error C2227: left of '->FluidFriction' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1083): error C2789: 'Friction': an object of const-qualified type must be initialized
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1083): note: see declaration of 'Friction'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1227): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1227): error C2227: left of '->FluidFriction' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1227): error C2789: 'Friction': an object of const-qualified type must be initialized
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1227): note: see declaration of 'Friction'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1299): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1299): error C2227: left of '->bWaterVolume' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1305): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1305): error C2227: left of '->bWaterVolume' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1328): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(1328): error C2227: left of '->TerminalVelocity' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(2372): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(2372): error C2227: left of '->bWaterVolume' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3216): error C2065: 'FDisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3216): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3216): error C2027: use of undefined type 'UCanvas'
2>  C:\Program Files\Epic Games\4.12\Engine\Source\Runtime\AIModule\Classes\Navigation/PathFollowingComponent.h(13): note: see declaration of 'UCanvas'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3216): error C2227: left of '->DisplayDebugManager' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3217): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3217): error C2228: left of '.SetDrawColor' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3217): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3219): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3219): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3219): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3222): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3222): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3222): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3225): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3225): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3225): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3228): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3228): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3228): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3231): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3231): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3231): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3238): error C2027: use of undefined type 'APhysicsVolume'
2>  C:\Program Files\Epic Games\4.12\Engine\Intermediate\Build\Win64\UE4Editor\Inc\Engine\MovementComponent.generated.h(15): note: see declaration of 'APhysicsVolume'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3238): error C2227: left of '->GetName' must point to class/struct/union/generic type
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3240): error C2065: 'DisplayDebugManager': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3240): error C2228: left of '.DrawString' must have class/struct/union
2>  C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3240): note: type is 'unknown-type'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3260): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3268): error C3861: 'DrawDebugDirectionalArrow': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3272): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3283): error C3861: 'DrawDebugDirectionalArrow': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3288): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3297): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3310): error C3861: 'DrawDebugDirectionalArrow': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3315): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3325): error C3861: 'DrawDebugString': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3400): error C3861: 'DrawDebugCapsule': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3401): error C3861: 'DrawDebugCapsule': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3499): error C3861: 'DrawDebugCapsule': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3500): error C3861: 'DrawDebugCapsule': identifier not found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3653): error C2065: 'UDestructibleComponent': undeclared identifier
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3653): error C2672: 'Cast': no matching overloaded function found
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3653): error C2974: 'Cast': invalid template argument for 'T', type expected
2>  C:\Program Files\Epic Games\4.12\Engine\Source\Runtime\CoreUObject\Public\UObject\Linker.h(2298): note: see declaration of 'Cast'
2>C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Source\Xs\NinjaCharacterMovementComponent.cpp(3653): error C2974: 'Cast': invalid template argument for 'To', type expected
2>  C:\Program Files\Epic Games\4.12\Engine\Source\Runtime\CoreUObject\Public\Templates\Casts.h(87): note: see declaration of 'Cast'
2>ERROR : UBT error : Failed to produce item: C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Binaries\Win64\UE4Editor-Xs.dll
2>  Total build time: 23.76 seconds
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(41,5): error MSB3075: The command ""C:\Program Files\Epic Games\4.12\Engine\Build\BatchFiles\Build.bat" XsEditor Win64 Development "C:\Users\...\OneDrive\Documents\Unreal Projects\Xs\Xs.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run  command.


dreyn your errors are caused by missing includes I think. For example


#include "GameFramework/PhysicsVolume.h"

will solve “error C2027: use of undefined type ‘APhysicsVolume’”.

On to my own problem:

I got it to compile on 4.12.0 (constraint of the project I am working on) except for one function I had to comment out:


protected:
	/** Called when the collision capsule touches another primitive component */
	virtual void CapsuleTouched(UPrimitiveComponent* OverlappedComp, AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) override;

Otherwise I get:


warning C4264: 'void UCharacterMovementComponent::CapsuleTouched(AActor *,UPrimitiveComponent *,int32,bool,const FHitResult &)': no override available for virtual member function from base 'UCharacterMovementComponent'; function is hidden

Is there something I can do to get to work with the protected function?

Yeah yeah, I didn’t want to waste time with git.

Maybe I deleted too much in the headers when updating code, the Unity builds may be the culprit. Sorry for that, let me know if you find the fix.

UCharacterMovementComponent::CapsuleTouched? Wrong namespace?

Namespace was correct. Discovered the problem though - different function arguments with engine version.



(AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)



(UPrimitiveComponent* OverlappedComp, AActor* Other, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)

@… Thanks for making the class available. Looks cool! A couple of questions thou… the custom gravity direction I can’t seem to get to work… I have a ‘planet blueprint’ where I’m casting to the movement component in order to set the direction as follows:


Also in normal operation (floor matching etc… ) the character gets all crazy… I think its something to do with rotating the character to the camera in it’s blueprint… but I havent dug much yet…


Maybe you have an idea?

Thanks again.

Was a bit worried that dynamic gravity won’t work with my custom root motion controller, but it looks like everything runs great. Thanks!

Try collection of includes in the NinjaCharacterMovementComponent.cpp file:


#include "Xs.h"
#include "NinjaCharacterMovementComponent.h"


#include "GameFramework/PhysicsVolume.h"
#include "GameFramework/GameNetworkManager.h"
#include "Navigation/PathFollowingComponent.h" // @todo Epic:  is here only due to circular dependency to AIModule.
#include "Components/DestructibleComponent.h"
#include "Engine/Canvas.h"
#include "PerfCountersHelpers.h"

================================================================================

Well, I hope my blueprint is helpful, make sure you read each popup on each var.

You’re welcome.

I linked my UE4 account with Github, I still get the 404. The post seems to be a little old, what happened to component? where can I get it ?

You have not linked your account properly. The page does not 404 for me.

Hi, I don’t know why I don’t have the ninja character movement


As you can see I have the ninja character c++ class working and I have the character movement but without the ninja part. How can I fix ?
PS: UE4 12.5

I took a look at your github and adapted some of your code to work as a child class of the character movement component instead of directly modifying it. My Z axis motion is still being killed somewhere though and I can’t figure out where. I overwrote any functions with “.Z” in them. Got any ideas of which functions to look at?

Edit: Input acceleration was being constrained in the tick

No idea, the NinjaCharacter must be using the NinjaCharacterMovementComponent, I just placed a NinjaCharacter in a simple level and everything is fine (UE4 12).

My code is currently a child class for any game project, you don’t have to recompile the engine.

Very Cool!

Hope can be integrated into the engine