Announcement

Collapse
No announcement yet.

Dynamic gravity for characters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hey Xaklse, thanks for awesome work! Have been playing around with the plugin for a few days now, and noticed one strange thing: character's velocity gets smaller for some little amount each time he steps on sloped surface. Felt it myself with walk speed cranked up to huge amounts, then tested with blueprint which compared current and previous velocity values, and current<previous happened exactly the moment character changed angle he stands on. Is this intended behaviour? If it is, can this effect be somehow cancelled out, so character remains constantly accelerating? Hope I explained the problem clearly

    Edit: Did more testing with bare NinjaCharacter_BP by just tweaking CharacterMovement parametres, found out that this oddity is especially noticable with high MaxWalkSpeed and low MaxAcceleration. For example I set those two to 3000 and 512 respectively, ran into the loop on NinjaTestMap at max (ie 3000) velocity, after that quickly slowed down to something around 1770 and stayed like that as long as character continued making circles. I use vectorlength of GetVelocity to measure current speed.

    Edit2: After more researching I came to conclusion that the reason may be some component of velocity being lost during angle change, same as you land after jumping/falling (for example if you landed on flat 0deg surface then Z part of fall velocity will be ignored). Tried forcing the character to maintain same speed when stepping on slope, but no luck.

    Edit3: Nevermind the previous blueprint, here's one that works. VHorizonAngle is an impact normal vector from CurrentFloor component. Dot product (ie cos) between its current and previous values pretty much determines amount of speed being lost during angle change, which can be cancelled out very easily.
    Attached Files
    Last edited by STourist; 08-09-2018, 09:32 AM.

    Comment


      I updated the NinjaCharacterMovementComponent.cpp to work with 4.20 (Epic did some changes causing errors in current code).

      I can post it here if that's okay with Xaklse, just let me know!

      cheers
      -Frank

      Comment


        Hi,
        I have everything working great, but I was just wondering if anyone has any suggestions on matching up gravity for other physics actors? I am fairly new to the engine so it might be a basic thing I am missing. Most of the solutions I have found have been pretty cheesy.

        Comment


          Hi,
          Any downloads available for 4.20?

          Comment


            It's ok Frank, feel free to post your version of the updated code; I just downloaded 4.20 and will update the code one of these coming days.

            Unfortunately for you Xenomatic, last time I checked, having custom gravity for physics actors requires changes in the engine, which were already posted on GitHub for old versions of the engine.

            Thanks for the feedback STourist, will review that example in detail.
            Ninja Character Code Plugin
            Visual Studio snippets for UE4
            ---------- ---------- ---------- ----------
            SonicGDK / Ashura: Dark Reign
            Heaven of Relics / Relic Madness

            Comment


              please update to 4.20!

              Comment


                For other actors you could set gravity to 0, and add a constant linear force in the same direction your gravity points. It's not the cheapest way, but if you tweak it so it'll only trigger in a close range around the player i think you'll be fine.
                I'll try upload my 4.20 changes tomorrow

                Comment


                  I uploaded the files for 4.20 here:

                  http://www.mediafire.com/file/e6qh93...acter.rar/file

                  just overwrite the existing files and you should be good to go (only 4 are updated, so keep the rest of the previous files in place)



                  Please note that there's currently a bug in 4.20 which causes intellisense to fail to include your header files. Resulting in a ton of compiling errors!

                  see this post on how to fix that:

                  https://forums.unrealengine.com/deve...02#post1504102


                  in addition, don't forget to add these paths also for the plugin to get properly build:

                  Code:
                  ..\..\Plugins\NinjaCharacter\Source\NinjaCharacter\Private;..\..\Plugins\NinjaCharacter\Source;..\..\Plugins\NinjaCharacter\Source\NinjaCharacter\Public;..\..\Plugins\NinjaCharacter\Intermediate\Build\Win64\UE4Editor\Inc\NinjaCharacter;..\..\Plugins\NinjaCharacter\Source\NinjaCharacter
                  they say it will be fixed in the next hotfix (4.20.3)

                  cheers!
                  Last edited by Frank Post; 09-11-2018, 02:09 AM.

                  Comment


                    What a surprise present from Epic... broken Intellisense. Thanks for the info Frank!

                    Ninja Character plugin for Unreal Engine 4.20.2 is up! Go to >> https://github.com/Xaklse/UnrealEngine << and grab the ZIP file (not the green button) from the link posted at the top part (if error 404: log in to Github, link your UE4 account to Github).

                    This is for C++-based game projects.
                    Last edited by Xaklse; 09-16-2018, 12:53 PM.
                    Ninja Character Code Plugin
                    Visual Studio snippets for UE4
                    ---------- ---------- ---------- ----------
                    SonicGDK / Ashura: Dark Reign
                    Heaven of Relics / Relic Madness

                    Comment


                      Fixed! UE-62042 Generate Project files does not add Intellisense include paths for .generated.h files
                      https://forums.unrealengine.com/unre...otfix-released

                      Comment


                        I just uploaded a new version with very minor code changes and an important change to fix non-Editor compilations.
                        I also added explanations about the input settings you need to test the sample content.

                        Ninja Character plugin for Unreal Engine 4.20.2+ is up! Go to >> https://github.com/Xaklse/UnrealEngine << and grab the ZIP file (not the green button) from the link posted at the top part (if error 404: log in to Github, link your UE4 account to Github).

                        This is for C++-based game projects.
                        Ninja Character Code Plugin
                        Visual Studio snippets for UE4
                        ---------- ---------- ---------- ----------
                        SonicGDK / Ashura: Dark Reign
                        Heaven of Relics / Relic Madness

                        Comment


                          Thanks for the update Xaklse !
                          a couple posts back you mentioned a replication bug. I was wondering what bug exactly, since I'm planning to add multiplayer to my project soon. Doesn't it work at all, or just some minor things?

                          thanks
                          Frank

                          Comment


                            Thanks for the update Xaklse !

                            Replication generally works, I noticed only one thing... if the character is on a moving surface - he shivers at clients

                            Comment


                              Originally posted by Frank Post View Post
                              Thanks for the update Xaklse !
                              a couple posts back you mentioned a replication bug. I was wondering what bug exactly, since I'm planning to add multiplayer to my project soon. Doesn't it work at all, or just some minor things?

                              thanks
                              Frank
                              Sorry for the big delay Frank.
                              A problem with ControlRotation happens to me with the "Run Dedicated Server" checkbox enabled:

                              (RGB is XYZ of ControlRotation)

                              The rotation is not right after changing between floor angles with big or very small differences.
                              This behaviour has changed for the better after upgrading to 4.20, the camera was also borked.

                              .
                              Originally posted by aGeronimo View Post
                              Thanks for the update Xaklse !

                              Replication generally works, I noticed only one thing... if the character is on a moving surface - he shivers at clients
                              Could you please elaborate a little more or show us a video?

                              Ninja Character Code Plugin
                              Visual Studio snippets for UE4
                              ---------- ---------- ---------- ----------
                              SonicGDK / Ashura: Dark Reign
                              Heaven of Relics / Relic Madness

                              Comment


                                https://www.youtube.com/watch?v=6ink4WGgbT4

                                Comment

                                Working...
                                X