Ninja Character - Dynamic gravity for characters & objects

Thank you so much for all of your hard work on this plugin, I think that it is an amazing tool that benefits the whole community. I have been playing around with the ExampleMap demo level. I am wondering if there is an easy way to set the character so that it will respond to a collision with a surface and orient itself to that surface in order to walk on it. In other words, jump from ground to wall and automatically orient to the wall and stick?

1 Like

do a line trace and off hit result get the impact normal and multiple it by -1 and set that to the “new gravity direction” pin of the “Set Fixed Gravity Direction” node, you’ll also need to cast the movement component to “NinjaCharacterMovementComponent”. Can also been seen in the video link I posted above, for when I was having desync problems.

1 Like

I didn’t see this mentioned in the thread but it looks like physics isn’t imparted to actors all the time. For example, if you go into the playground at the end of the example map and orient yourself so you and your gravity is perpendicular to one of the sets of 3 cubes of descending size and then jump into the smallest one, it doesn’t move at all. If you go back so you’re on the same plane as the cubes, you can run into them and they move just fine. Is this a bug, a limitation or just something that needs to be configured differently?

Hi @Xaklse, i seem to have an issue plugging in the character movement component into “Set Fixed Gravity Direction”. When I hover over the character movement component, it does say it’s the Ninja character, and it’s parented correctly. This is your Character in the plugin. i can’t compile without a target, but when I drag out, I don’t have any options other than casting to the character movement. But if I cast, I’m not sure what to plug into the “Object”.

Sorry but I couldn’t reproduce the issue you’re describing, I tried several orientations but the smallest cube always moves after landing on it from a side. A recorded video or a map file would help to see what’s wrong.

.

The “Character Movement” node you have there is a standard CharacterMovementComponent, you have to convert it to NinjaCharacterMovementComponent first; mouse-drag from the blue pin of the node to anywhere, a pop-up appears, make sure the “Context Sensitive” checkbox is active, search for “ninja” and select the casting option; the result should be a valid Target for the “Set Fixed Gravity Direction” node.

It works great for moving objects so I’m wondering if I could attach a volume to a flyable ship so players can walk around while it flies. Is it possible to use in a volume for this? So far I’ve only figured out how to make the chaarcter attach to all meshes.

Here’s a video:

If it’s not enough, is putting just the .umap file up somewhere for you enough(new to Unreal, not familiar with asset distribution)?

I ignore if volumes can be movable, but consider using a trigger actor instead.

.

Thank you, this is what I needed to understand the issue, which is real. I’ll take a look but I think it’s heavily related to Epic’s implementation.

.

[USER=“107215”]Frank Post[/USER] [USER=“4519”]Basement Bob[/USER] @ksimpson1986 @err0s
New version is up, compatible with UE 4.25.

1.08.25:

  • Added generic code in NinjaMath that determines if two unit vectors are orthogonal/parallel.
  • 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 Help folder with ‘Changelog’ and ‘How to use’ text files.
  • Transformed wrong Client RPCs into NetMulticast RPCs in NinjaCharacterMovementComponent.
  • Added SmoothComponentLocationAndRotation Blueprint callable function to NinjaCharacter.
    — Smoothly interpolates location and rotation of an attached component; check 1.5 section in example map.

New 1.08.26 version is up, compatible with UE 4.26.

Hey. I am trying to get plugin to work with first person view. The camera is attached to the SpringArm, but when moving sideways, the controller’s angle is not updated. The update of the direction of gravity occurs through the SetFixedGravityDirection. Maybe You can help with this problem.

Hey man, brilliant plugin i love it, because i can customize my character, i implemeted it, it works nice, but i have 1 issue and 2 questions:
Question 1 - i want to set a gravity field for my planets, how do i do it, there is no tutorial for that
Question 2 - how do i use this plugin on objects

for my issue, i don’t want my character to align to surfaces i want my character to align with center of planet, i’m using voxel plugin planet,
with the hills and mountains, my character aligns with slopes, it’s not realistic, i need it to be always aligned with center of planet,

can you help please ?

Sorry for the late reply, busy times at work. Thanks for the update Xaklse, much appreciated!!

On your spring arm component, did you enable ‘Use Pawn Control Rotation’ and inherit all axes (yaw/pitch/roll)? Also, be sure the rotation on your spring arm isn’t set to absolute in its transform properties.

set the ninja properties like this:


Then you can use the “set Point Gravity Direction” function to set a location to which the gravity points to (in your case the center location of your planet).

You could use trigger volumes/meshes (on begin overlap) to set a new gravity direction. I’m using this method to change gravity to switch between directional and point gravity.

I use a spherical world/planet with buildings in which I want the gravity to be directional once the player enters a building, and to be directional to the planets center once you exit a building

I created a component derived from StaticMeshComponent, using its BeginOverlap event to trigger the changes in gravity. This component can then be added to any actor. The reason I derived it from staticmeshcompoennt is to have a custom mesh (trigger) assigned, matching the shape of the volume in which I want the gravity to be altered.

0d5a80e543f2230130c601fb3c8274d542472070.png


https://forums.unrealengine.com/core/image/gif;base64

Don’t mind the mockup meshes, but here you can see the blue mesh (from the staticmeshcomponent) I use to trigger the different gravity directions.

using custom gravity on objects depends on what kind of object/movement it needs. Is it physics simulated? If so, you could disable the gravity on the physics properties, then add linear velocity on tick in the direction of your gravity. When using point gravity on a planet located at world 0,0,0 you can always normalize an actor/object location, then negate it to get the direction vector pointing to the center of your planet (thus matching your gravity direction around the planet).

hope this helps!

cheers
Frank

edit: updated the image links hopefully theyre visible now

the images are not loading, i can’t see the settings, i tried on other browsers and nothing !!
what’s happening !!

We’re developing a Ninja Game using Ninja Character - Dynamic gravity for characters & objects. Just curious if anyone else is doing so :slight_smile:

(Sorry for the big delay) As Frank Post replied, review the spring arm properties; not only that, check my blueprint examples and take a look to the few properties I changed in the actor and its components (which can be spotted thanks to the small yellow undo arrows) and try to understand the reason behind each change.

.

Check the example map, section 2; PhysicsVolumes are required.

.

Thanks for posting, I’d like to know about projects that use my plugin :wink:

Hi @Xaklse In the Marketplace its stated “Network Replicated: No (needs more work)”, What is needed to fully support Network Replication?

The worst part causes desyncs between clients regarding actual position and physics mode of each character.
There are also some visual glitches of the skeletal mesh component that need to be fixed (which might be a symptom of something more serious).

Perhaps there is possibility to compensate for desyncs by multicasting the position at specified tick frequency and interpolation locally?

[USER=“107215”]Frank Post[/USER] @Xaklse thank you so much for the advice!! your mockup is fine man, no worries !!
i will need to change gravity directions too, directional on spaceship, point gravity direction on planets, your example of directional for buildings and point direction for planet is similar to mine
i’ll definitely do that, can i just use Cube+Arrow / Sphere overlap inside an actor ( that i will name gravity field ) to switch gravity direction ?
i wanna use the cube +arrow for directional, on the space ship, and then a spherical one for planets
please advice me on that if you can, and happy new year !!

Thanks, its just a slow process, we’re just a 2 man team both working fulltime in the game industry by day, so only got some hours in the evening to work on this project!
You can easily use sphere/cube collision overlaps. Its actually easier than mesh overlaps, those often get buggy results (need convex auto generated collision, else the overlap events trigger inconsistently). You can try to lerp to the target gravity vector to get a smooth transition. You can always send me a pm if you need any help.