Download

Ninja Character - Dynamic gravity for characters & objects

Hello, can we use this plugin for commercial purposes?

And 2. Question: How can i switch the modes how the character will walk on the surfaces and how the gravity will be?

Because when i jump it sets me back to the normal ground, but i want to jump on other objects they are in the same direction.

And will it be possible to switch the modes by pressing a key?

I don’t see stuttering when disabling the Network Smoothing, and the screenshot below is non-destructive code that I started so if you leave the additional variables I added (fdelayBetweenControlRotationUpdates and timeForControlRotationToComplete) as their defaults then your code will run for higher poly count geometry.

I will have harsh geometry changes, this is the game here: Untitled Gravity Game Demo by Erros (which has camera rotation lag of 2 enabled to make it so the gravity updates aren’t too jarring however that makes the looking around feel sluggish and if you move the mouse too fast then it does a little stutter). The pickup spawner relies on the polycount of the sphere being low as it uses the “Get Section from Static Mesh” Node to place all of the items, so that I or someone else does not have to hand place them.
In their demo if you go to the sphere, you are able to tell it is a low poly sphere where the difference in the angle between normals is bigger then the hollow cylinder at the beginning of the level and still results in a smooth transitition.

The problem with the spring arm approach is the smoothing is only applied to the player’s input, whereas if you change gravity, like shown in the video I posted, then the spring arm won’t remember where it was in world space but will remember it’s rotation offset from the mesh so it will still change by that abrupt amount which is what I’m trying to fix. Also the only way to set the camera rotation is through the control rotation as the player controller will override any camera specific rotation functions, and I don’t know how to correctly apply the “Get Gravity Direction” function to the Quaternion that controls the view rotation (control Rotation). I assume it would be through Quaternion Multiplication however I’m not sure how to create a Quaternion from the up vector where it stays the up vector. I could easily get the forward and right vectors too but not sure how to combine all into a Quaternion.

So I got in contact with the creator of the demo and it turns out it is spring arm smoothing with parent rotation not inherited, so your suggestion was 100% correct. Now I just need to figure out how to incorperate it into the plugin. Sorry for my previous comments I’m still learning ue4 and a bit impatient.

I’m having the same issue.

I aborted using ALS and went with a custom animation system.

I aborted effort to integrate Ninja with ALS. Went with a custom Animation BP using Ninja.

I also went to custom animations for Ninja Character. And there are IK plugins out there also.

Hello I just wanted to ask a quick question on controlling where the ninja plugin works and where it doesn’t

I want to be able to turn on and off the power depending on where the player is located (Like within a triggerbox) But i can’t seem to find a way to disable the Ninja Plugin

I’m not well verse with programming, I’m still learning, So any help in how to achieve this would be great :D! Thankyou

First of all, thanks for this great plug-in! I’ve been working on planetary movement (running around the outside of a very large sphere), and this has saved me a lot of time and effort making that work.

But, there’s one odd bug I’ve encountered, and I’m not sure how to even start debugging it. Whenever a NinjaCharacter gets within about ~10 degrees of the south pole (eyeballed, not precisely measured), it vanishes. Like, the actor is suddenly entirely gone from the scene graph. Nothing appears in the Output Log when it happens.

This occurs even when I just take the built-in “NinjaPlayerCharacter_BP” and drop it on a newly created sphere in an otherwise empty map, so I’m pretty sure it’s not related to anything funky I’ve done. (Though it’s challenging getting that default character blueprint to the south pole given how it’s camera moves. :smile: )

It’s me again. I got another weird problem on my hands.

Basically, I gave my Character some attacks, and whenever he attacks, he turns to wherever the Camera is facing (within the Yaw Axis). However, I also wanted to have this mechanic on Gravity as well. So, I set up an Arrow that only relatively rotates from the Camera’s Yaw axis (meaning, no matter what gravity direction I am on, the Arrow will always be able to rotate around the Character a complete 360 degrees), and set the rotation from that arrow. Sounds like it works, right?

Here is where the problem lies. For some apparent reason, whenever I face left or right on a vertical wall, it works normally; however, as I try rotating closer and closer to either up or down on the wall, my Character starts moving a lot. It isn’t until I am pretty much up or down, that if I hit the attack button, the Character falls off.

I have no idea why this happens. It doesn’t have to do with the Animations, because I even turned those off, and it was still causing the same problem. Here are the calculations for both the Attack Rotation, and the Arrow Rotation, in that order (as a side note, the “Convert To Local Rotator” function is just a Get Actor Transform with an Inverse Transform Rotation):

Any help would be appreciated.

Okay, nevermind… The problem was just that I was hitting the world’s KillZ. I reset that, and now it’s all good.

This was answered in Marketplace questions:
From the Unreal Engine Marketplace FAQ: “you may use Marketplace products in your own shipped products”
The provided example map has 3 switches/buttons that toggle some gravity settings, near the end of the corridor, on the right side. Also make sure you check the level and character blueprint graphs to learn the nodes you need to use.

.

By default, a NinjaCharacter behaves like a standard Character; changing values of exposed properties allow ninjas to walk on walls or fall towards other gravity directions.
Example level blueprint to disable wall-walking within a trigger box:

.

Heheh, I remember having the same problem a decade ago, old times…

.

Sounds like the classic gimbal lock problem, but it’s hard to see what’s the wrong part in this case. Working with decomposed Rotators usually leads to buggy orientations, so try to find a solution that doesn’t rely on them.

I actually managed to figure out the problem here. I had a separate Capsule Component that had it’s Rotation set constantly so I could “highlight” where the Character was going to rotate.

What I saw with what I had was that when I looked up or down, the Capsule flipped sideways, which if I hit the attack button, I would fall off immediately. Basically, the problem was perhaps bad Rotation Calculation.

I did improve what I had, though, and I was able to fix the Rotation on the wall, so now I can freely look anywhere and not fall off. However, when I’m on a Sphere (or any irregular shaped object), the Sideways Capsule starts appearing again. I honesty think that the Rotation is still not being calculated correctly, so I might have to improve it a bit.

I managed to fix the problem. I found the actual culprit to the problem:

It was this guy. Once I disconnected that and only set Z Axis for the Relative Rotation of the Arrow, I then set the Actor Rotation from the World Rotation of the Arrow… and it somehow worked.

Thanks for helping me with some of the problems! :smiley:

New version is up, compatible with UE 4.26.

1.29.26:

  • Added Epic’s missing code changes that were written between UE 4.22 and 4.23 releases.
  • Amended incorrect notes of SmoothComponent Blueprint functions.
  • Return UpVector constant in GetComponentDesiredAxisZ instead of in GetComponentAxisZ.
  • Added SetCharMovementAxis Blueprint callable function to NinjaCharacter.
    — “Change Char Axis” node allows rotating the collision capsule and force-walk unwalkable surfaces.
    — “On Unwalkable Hit” event is triggered when the collision capsule bumps into an unwalkable blocking object.
    — “Trigger Unwalkable Hits” checkbox controls unwalkable hit events.
  • Used a quaternion to rotate the ControlRotation in OnCharMovementAxisChanged.
  • Added GetAxisZ function of an FRotator in NinjaMath.
  • Replaced uses of 0,0,-1 vector with DownVector constant.
  • Used HALF_PI constant instead of PI/2.
  • Deleted unneeded trigger of 1.3 example because OnMovementModeChanged’s code was changed to rotate around center of collision capsule.

1 Like

Hello everyone, this is an awesome plugin. I’m currently having fun while looking at it but I have a small issue.

I reparented the default ThirdPersonCharacter to the NinjaPlayerCharacter_BP.
I then trace on event tick to find a wall in front of me where my character need to rotate to (and apply new gravity from that wall)

I used “Set Fixed Gravity Direction” and “Set Collision Gravity Direction”, but in my case, it looks like both are doing well for my needs.
It works as intended, however the only issue I got is when my character is moving on the wall.

The rotation of the character isn’t oriented where I am moving. It does the same thing on solo, or multiplayer.
I tried to look at the default NinjaPlayerCharacter_BP for every component properties, but I can’t find the issue.

If needed, I can record a video of the problem.

Thanks for reading, and many thanks for the awesome plugin. I’ve been looking for something like this for a long time.

The blueprint graph you posted looks fine, I tried to replicate your problem in my example map with the ‘platform stick’, added the “align component to gravity” node, and disabled all align-like checkboxes in the CharacterMoveComp blueprint; the Character is attracted by the ‘platform stick’ and the collision capsule rotates with gravity.
Something else must be wrong, or you’re testing against a collision shape I can’t imagine without a description.
Record a video with what you have, or try to use the new Change Char Axis node I added with the newest udpate.