Ninja Character - Dynamic gravity for characters & objects

@Xaklse i need your help with something, i wanna start a game with you ninja character as base for main character and NPCs/Enemies, with c++, how should i approach this ?
should i make a child class ? if i make a child class, will the defined functions in NinjaCharacter.cpp file will carry over to the child class ?

Hello!
I am very excited that you made this plug-in and grateful to use it. However, I followed the directions and could not get it to work. I believe the misstep would occur with picking my blueprint for my character as the default pawn class. I tried to fix this but this is too difficult to do on my own. Here is a picture of my Game Mode from the World Setting menu.

Can you please help me? My Discord ID is Locke Delasol#5760 . I will also frequently check this webpage for a response.

Yeah, create a C++ child class of NinjaCharacter and it will inherit all the gravity-related stuff. There is a catch if you don’t use blueprints: you have to code input handling, exactly the same ‘problem’ as if you would use a standard Character, I’m sure there are dozens of tutorials covering that, or check how it’s done in a new C++ project created through the editor.

.

It looks okay to me, look elsewhere. What do you mean with “could not get it to work”? Can’t you move?

Sorry, but I’m using AlignComponentToGravity (not AlignComponentToFloor) and SetFixedGravityDirection. It is more flexible for manual gravity controlling. And You don’t using SpringArm on camera, and i think it is main problem. I think SpringArm is calling that issue.

@Xaklse here’s my project, some cool application for Ninja Plugin, hope you like it Unreal Engine 4 drag effect on a moving platform - YouTube
i’m converting people to your plugin, LOL, they can’t go back after trying it.
how is the replication in the plugin ? is it online ready ? i’d like to start an online prototype game, and improving it as i go.

Yes this does work. I guess I’ll look into what I am missing on my end. Thanks!

Attach a new SpringArm component to the CapsuleComponent, attach the FirstPersonCamera to the new SpringArm, configure SpringArm with “Target Arm Length” set to zero and tick “Use Pawn Control Rotation”. No issues yet.

.

It’s nice to see the plugin in use, you’re having fun.
Online aspect still isn’t ready for production, check the release notes of future plugin updates to be informed.

.

Thank you for checking.

@Xalkse please man, work on the replication please !!

Hi

I’m trying to smooth my Character’s Mesh and Camera, but I can’t seem to figure out the math for it. I’ve been having trouble with it for a while.

Basically, I have no idea how to calculate this because I’m not good with Rotation math. What I’m looking for if this is possible in Blueprint (I don’t have much knowledge in C++), and none of the jittery movements while walking across the surfaces of objects. I want both the Mesh and Camera to be smooth, even if I was walking on a somewhat low poly Cylinder (Camera Rotation Lag won’t work, because we have something set up for the Camera that would be messed up if we changed the Lag speed).

Any help would be appreciated.

1 Like

@Zanthuros i’m trying to do the same thing for the camera, i believe the rotation is handled in the ninja camera manager.
i don’t know about the mesh rotation yet,
for the camera rotation, you can get the cross product of the controller right vector with the character capsule up vector to to find the forward vector at the new angle
you can use “make rotation from axes XY” X is the new cross product vector, and Y is the right vector of the controller
then you have to get the difference between the previous rotation and the new rotation you just calculated
add the result rotation to your current controller rotation.
add me on discord IdirFETT#6735 if you have it, 2 minds are better than one alone

EDIT: maybe this is just for pitch only !!

I just want to point out that the “Enable Camera Rotation Lag” setting on the camera boom of the default third person character is set to false. Enabling it and setting “Camera Rotation Lag Speed” to something like 10-20 can help a lot with smoothing out tight transitions. The NinjaPlayerCharacter_BP has it enabled and set to 10 by default. (I was trying to figure out why my version was so much more jittery than when I used the plugin’s default, so I put them side by side and found this)

have you tried it with your character standing on a rotating platform ?

Pretty cool plugin! Is there any way to get rid of the jittery motion though? I’m using SetFixedGravityDirection() every tick and the character is oriented towards gravity. It’s based on the demo from the plugin, but with that portion changed obviously. Though if you go to the demo there’s noticable jitter when standing on the rotating platforms well.

In my test (on a sphere) it’s most obvious when strafing and more obvious the less tesselated the sphere is.

I noticed you added revert to default gravity under character movement, and I read the tool tip about it activating when entering a default physics volume, but I’m unable to get it to work. I place the volume on underside of a plane but when I walk into the physics volume nothing happens. What I assume would happen is whatever gravity the player has currently would be overwritten with -1 * their current gravity and then the player would fall in that direction and upon hitting the opposite plane rotate to match that plane’s normal.

Also I tried to solve the smooth camera on low poly terrain but was unsuccessive, however I got rather close. Here’s the video showing it off: Ninja Character Plugin Smooth Camera Attempt - YouTube maybe someone will figure out a solution just by watching it. I don’t know if I can copy and paste my changes since the creator has a copy write on the code but if it’s cool with him then I can pastebin it or place it in text files for the two files I changed.

1.08.25 version from December added stuff to smooth the Mesh rotation and to allow up to 4 rotations per degree for the CapsuleComponent.

  • Added configurable ThresholdParallelAngle float to NinjaCharacterMovementComponent.
    — Reducing this value improves perceived smoothness of certain rotation calculations, allowing more collision capsule rotations on moving bases.
  • Added SmoothComponentLocationAndRotation Blueprint callable function to NinjaCharacter.
    — Smoothly interpolates location and rotation of an attached component; check 1.5 section in example map.

Make sure you “Enable Camera Rotation Lag” in CameraBoom too (that’s what I have used @Zanthuros, sorry if you can’t use it). Let’s see if it works for you people.

.

You probably need to “launch” the Character so that it starts falling in the direction of the new gravity. Wondering how to do that without lots of nodes if you have many physics volumes.

:confused: I just noticed that Epic didn’t publish the 1.15.26 update, which was intended to fix the publication of 1.14.26. So you’re probably stuck with the old 1.08.26 version which doesn’t have some of the smoothing stuff. I just submitted the new 1.20.26 update, so let’s see what happens with publication next. :wink:

Thanks a lot Xaklse. Really nice plugin.

You’re welcome!

.

New version is up (that was fast Epic!), compatible with UE 4.26.

1.20.26:

  • Allowed simulated NinjaCharacters to find any floor while falling if LandOnAnySurface is marked.
  • Remade MakeFromZQuat function: now it flips control rotation when capsule rotates 180 degrees (if applicable).
    — Harsh 90 degrees rotation of NinjaCharacter is also improved.
  • Replaced use of SCENECOMPONENT_ROTATOR_TOLERANCE number with the configuration value called ThresholdParallelAngle.
  • NinjaCharacter logs error and doesn’t smooth Mesh if NetworkSmoothingMode of CharacterMovement is enabled.
    — Allows smooth interpolation of attached skeletal mesh component in remotely controlled NinjaCharacters.
  • Added NinjaFallVelocity to NinjaPhysicsVolume that imparts a falling velocity to entering walking NinjaCharacters.

.

@err0s
Try the new NinjaFallVelocity of NinjaPhysicsVolume.

I updated to 4.26 to try some of the new features, the NinjaFallVelocity is a great addition. I think a notify to the player character would be a nice addition to allow the designer to add additional mechanics on or a way to know when to play certain animations. For the smoothComponent functions, in multiplayer they cause stuttering when sending data from the client to the server, however server to client has no stuttering.

The biggest problem I have with the smooth Component Rotation functions is your solution to a smooth camera is to attach it to the mesh and turn camera lag on, though it helps greatly with the nausea caused by rapidly updating the controller control rotation, it makes the mouse feel incredibly sluggish. There’s an article I found that talks about using two quaternions to achieve smooth camera rotation and smooth mesh rotation here: The Journey To Satisfying Character Movement — 9.8 . I played their demo and can say for certain that the camera is incredibly smooth, I tried to reproduce the effect as seen in the youtube video I posted earlier. Since posting the video I made it so the mouse can update the control rotation without delay while the rotation between planes is smooth but the camera still suffers from over rolling as I’m not knowlegable enough about the Math behind Quaternions and the Twist Swing technique that the article uses.

I know the instant update of the camera doesn’t bother you directly but not everyone has a strong stomach.

1 Like

Can’t you use the OnMovementModeChanged notify in Character? Do you still see stutters after disabling NetworkSmoothingMode as mentioned in the release notes?
.

(After watching your whole video, playing the demo game)
Questions first: do you intend to have harsh changes of geometry/gravity like in your video or smoother geometry like in the demo? Will your game be ‘similar’ to the demo in functionality?

I think it isn’t a good idea to smooth the player control rotation, it should be more deterministic. Smooth the SpringArm instead: place it at the center of the bottom sphere of the collision capsule and smooth its rotation with BPs or C++ code (you’ll need to apply an additional offset to compensate the location). And/or smooth the CameraComponent with BPs or C++ code. I also suggest to use “Get Gravity Direction” from NinjaCharacterMovementComponent as a vector that determines the camera Z axis, to obtain the same great smoothness of the video.