Ninja Character - Dynamic gravity for characters & objects

to let you know I checked your code and by removing the override at the end of line 607 i think it was this plugin will work on UE 5.1 and compile, it looks like there are some name changes

so i’m trying to find some info on how you implemented you gravity on object not characters and i’m not really finding anything. any help?

Sorry if this is a dumb question but how can i set the direction of gravity directly in the blueprint? I have my own solution(component) for determining which direction that should be but your character works a bit better than mine so I’m testing it out. awesome that this is free btw, thanks. wish i found it before i spent all that time on a custom pawn…

ok i found setfixedgravitydirection(target the ninja, had to click no context cuz it didnt want to show up for me or im dumb).
Is setting that every tick the best way to go about this? any setting I should enable or disable that you can think of. Its KINDA working so Im sure ill have to tweak.

Hello, I’m testing the 8 Way Movement again.
How do I solve the Axis problem on walls?
Ref:
GIF 05.12.2022 12-58-40

There might be a bug here. The NewDelta.Z is negative when i move up on a ramp

FVector UNinjaCharacterMovementComponent::ComputeGroundMovementDeltaEx(const FVector& Delta, const FVector& DeltaPlaneNormal, const FHitResult& RampHit, const bool bHitFromLineTrace) const
{
	const FVector FloorNormal = RampHit.ImpactNormal;

	if (!bHitFromLineTrace && IsWalkable(RampHit))
	{
		const FVector DeltaNormal = Delta.GetSafeNormal();
		if (DeltaNormal.IsZero())
		{
			return DeltaNormal;
		}

		if (!FNinjaMath::Orthogonal(DeltaNormal, FloorNormal, ThresholdOrthogonalCosine))
		{
			// Compute a vector that moves parallel to the surface, by projecting the horizontal movement direction onto the ramp
			// We can't just project Delta onto the plane defined by FloorNormal because the direction changes on spherical geometry
			FVector NewDelta = FQuat(DeltaPlaneNormal ^ DeltaNormal, FMath::Acos(FloorNormal | DeltaPlaneNormal)).RotateVector(Delta);

			if (bMaintainHorizontalGroundVelocity)
			{
				const FVector NewDeltaNormal = NewDelta.GetSafeNormal();
				NewDelta = NewDeltaNormal * (Delta.Size() / (DeltaNormal | NewDeltaNormal));
			}

			return NewDelta;
		}
	}

	return Delta;
}

I could remove a single word, let the plugin compile and upload a new release; then you wouldn’t get all the Character-related changes that Epic added for 5.1.

I don’t want that, so it takes me hours to review all Epic changes and adapt them to Ninja; but don’t worry, the full proper Ninja 5.1 update is submitted (pending approval).

Check the NinjaPhysicsVolume.

Using SetFixedGravityDirection is fine, but I don’t know what you’re trying to do (not enough info). Make sure you check all the “ninja” (search with that) options in the NinjaCharacterMovementComponent of the NinjaCharacter blueprint.

I’m sorry, I don’t have a guide on how to do that properly, if it’s possible. Is there a free marketplace asset to test the animations?

You’re right, that’s a bug!

Use this instead if you can compile code:

			// We can't just project Delta onto the plane defined by FloorNormal because the direction changes on spherical geometry
			FVector NewDelta = FQuat(DeltaPlaneNormal ^ DeltaNormal,
				(((FloorNormal | Delta) > 0.0f) ? 1.0f : -1.0f) * FMath::Acos(FloorNormal | DeltaPlaneNormal)).RotateVector(Delta);

thank you very much !

Hello and thank you for such an awesome plugin, I have kind of a weird situation and was wondering if you knew how to make this work for it, or if it’s even possible.

We have a moving airship, we want to use this to change the players gravity to “stick” to the deck, so that they can run around and jump around on the deck of the ship while it’s in motion. So far when we do it, the character definitely sticks better than default movement component, but still flies across the deck as if the ship is moving “under” it. Is there a way to have the players stay relative to the ship’s motion ?

So if i jump while the ship is moving, I land right back where i started?

Thanks, I indeed got it working by looking at code and fiddling with all the settings for a few days. Lovely plugin so far, everything works better than what I had going. Much better.

New question(s) about the camera.

  1. I’d like the camera to be able to fully rotate around the character. I dont want it to stop rotating when it gets above my character or below. Just keep going and now we are looking at the character upside down.

  2. I’d like to have it auto adjust only the roll of the camera when our gravity direction changes. leave the pitch and yaw to only the players input(aside from correcting for in-the-way geometry).
    Or at least no auto adjusting at all and i can figure out how to correct the roll later maybe…
    Messing with the inherit stuff hasn’t helped. I even tried un-rotating the camera using the change in gravity between frames and that’s when i decided i was being silly by not just asking someone smarter.

Hope this is clear. also trying to search these forums for answers is a nightmare so im sorry if this info is somewhere in here…

The engine only has “Impart Base Velocity” settings that are enabled by default; if you jump, ship velocity is added to jump velocity, only in that moment of time, that’s all.
You probably could find a solution through blueprint use.

  1. Create a NinjaPlayerCameraManager blueprint and edit its “View Pitch” angle values; open your PlayerController blueprint and change its “Player Camera Manager Class”.
  2. Inherit stuff won’t help there… if you can read code, you can get hints in ANinjaCharacter::OnCharMovementAxisChanged. Basically, you have to adjust Controller’s ControlRotation whenever gravity direction changes, with the help of quaternion calculations, and make it work the way you want.
  1. Awesome. it acts weird at the “top” and “bottom” when passing the old threshold but its not too bad for the most part. The cam seems to want to roll but then changes its mind.
  2. Not great at reading code but I am getting better as I write & read more and am slowly understanding the plugin better. Ill keep trying. Need to get my head around these rotations…

Its funny to me that to emulate my desired behavior, i can just move the camera in game as my orientation changes and be like this is how i want you to behave Cam. But to make it happen thru code, automatically…

Thanks for taking the time.

Digging into source to see if I can combine some features of this into another plugin’s custom movement component.

But before I do, I’m trying to see if this can even do what I want.

Is there a way to have it so that you don’t depend on just walking up a curved platform that angles up or down but can instead jump onto any wall?

the “on unwalkable hit” will trigger when you jump or walk into a wall that is too steep for your character to walk up normally

Hi
I’m trying to add new animation to Ninja. But this animation is not work and strange when he is on a wall or a ceiling. that is because I think the animation uses world direction,not local direction (Character Normal Vector)
Please tell me how to add new animation.

I’m really glad to answer my many questions! These questions are very used by my project. I hope this community will be activated until next year and after!

Happy(almost)New Year!!

Absolutely phenomenal work. Thank you! Just one question. I know AI nav mesh isn’t supported. So how would you go about implementing basic ai move to using this? Say having ai ninja on a sphere and it finds an object on the sphere and moves to it while avoid obstacles? Just need an idea of how to start implementing this.