Announcement

Collapse
No announcement yet.

Dynamic gravity for characters

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

    #31
    thanks for the hard work, I really hope this gets merged in soon

    Comment


      #32
      this looks really cool, would love to try it. problem is im really inexperienced with github so i cant seem to find out how to get hold of the two files, or a copy of the entire project with the two files merged. i do have epic linked git account so thats not the issue.

      Comment


        #33
        If you just want the code, visit each link and click on the "Raw" button (there might be a better way):
        https://github.com/Xaklse/UnrealEngi...entComponent.h
        https://github.com/Xaklse/UnrealEngi...tComponent.cpp
        Remember to recompile the engine code.


        Originally posted by a_najafi View Post
        hey there i was wondering how you acheived to get the gravity to be the center of the sphere or in general how to make the gravity based on the floor angle (i could probably set it up using the ray trace to the floor from the character but just wondering ) )
        also could you refer to us where you set up the gravity stuff so we could possibly change the gravity of actors in general (now that would be legendary)
        Use this code in the .cpp file (find and replace functions):
        Code:
        void UCharacterMovementComponent::UpdateGravity(float DeltaTime)
        {
        	if (IsMovingOnGround())
        	{
        		SetGravityDirection(CurrentFloor.HitResult.ImpactNormal * -1.0f);
        	}
        
        	UpdateComponentRotation();
        }
        
        FVector UCharacterMovementComponent::GetComponentDesiredAxisZ() const
        {
        	if (IsMovingOnGround())
        	{
        		return CurrentFloor.HitResult.ImpactNormal;
        	}
        
        	return GetGravityDirection(true) * -1.0f;
        }
        About changing the gravity of other actors, I didn't do anything about that, but I remember there were threads about that matter in these forums.
        Dynamic gravity for characters
        Visual Studio snippets for UE4
        ---------- ---------- ---------- ----------
        SonicGDK / Ashura: Dark Reign
        Heaven of Relics / Relic Madness

        Comment


          #34
          Originally posted by Xaklse View Post
          If you just want the code, visit each link and click on the "Raw" button (there might be a better way):
          https://github.com/Xaklse/UnrealEngi...entComponent.h
          https://github.com/Xaklse/UnrealEngi...tComponent.cpp
          Remember to recompile the engine code.


          Use this code in the .cpp file (find and replace functions):
          Code:
          void UCharacterMovementComponent::UpdateGravity(float DeltaTime)
          {
          	if (IsMovingOnGround())
          	{
          		SetGravityDirection(CurrentFloor.HitResult.ImpactNormal * -1.0f);
          	}
          
          	UpdateComponentRotation();
          }
          
          FVector UCharacterMovementComponent::GetComponentDesiredAxisZ() const
          {
          	if (IsMovingOnGround())
          	{
          		return CurrentFloor.HitResult.ImpactNormal;
          	}
          
          	return GetGravityDirection(true) * -1.0f;
          }
          About changing the gravity of other actors, I didn't do anything about that, but I remember there were threads about that matter in these forums.
          Hi ! Con you re-up your work ? Thank

          Comment


            #35
            The source code is still there and available. Log in to Github.

            Comment


              #36
              Originally posted by ambershee View Post
              The source code is still there and available. Log in to Github.
              Now work i forget to link my UE4 account to Github
              Last edited by Gui205; 04-17-2015, 10:24 AM.

              Comment


                #37
                Originally posted by ambershee View Post
                The source code is still there and available. Log in to Github.
                Bolded for emphasis. If you have set up an Unreal Engine account and followed the instructions to access the UE4 source code on Github, you will be able to see the forked repository when you log in.

                Comment


                  #38
                  Just what I'm after (I think, grabbing the code and testing to see if it suits)! Thanks for sharing .

                  Comment


                    #39
                    i downloaded the modified unreal version and compile it then i created a third person template and it does not seem work, can someone guide me or tell me if there is other steps i skept or still to do??

                    Comment


                      #40
                      Hey everyone,

                      I was wondering how could incorporate this into a blueprint project?

                      Comment


                        #41
                        Hello Guys,

                        I know all here have many Projects and Work but us hopeful that anyone can help us.

                        We are an Academy for 3D Artist in Germany and like the Projects on our Students make alive to show up for the Gameindustrie.
                        We are no Programmer so we need help to create Template(s) to create good Portfolios for our Students.

                        We need this for a Jump and Run Template for a Portolio to let the character run in a loop (like Sonic), we are no Programmer / Coder.
                        Also, we need exactly a Guide / Tutorial to Implement this or a other way to do it.

                        Can anyone help us please.

                        Thank for share all you Knowledge on this Forum you are really great community!!!
                        A Special thanks to Xaklse for sharing this code

                        Comment


                          #42
                          Any chance for re-upload code?

                          Comment


                            #43
                            The code is Avalible on Github (u need only add EpicGame to you Account!)
                            Last edited by Kosrona; 07-19-2015, 09:10 AM.

                            Comment


                              #44
                              same here but where to Compile it? isnt for Version 4.8 right?
                              Last edited by Kosrona; 07-20-2015, 03:26 AM.

                              Comment


                                #45
                                Originally posted by Xaklse View Post
                                If you just want the code, visit each link and click on the "Raw" button (there might be a better way):
                                https://github.com/Xaklse/UnrealEngi...entComponent.h
                                https://github.com/Xaklse/UnrealEngi...tComponent.cpp
                                Remember to recompile the engine code.


                                Use this code in the .cpp file (find and replace functions):
                                Code:
                                void UCharacterMovementComponent::UpdateGravity(float DeltaTime)
                                {
                                	if (IsMovingOnGround())
                                	{
                                		SetGravityDirection(CurrentFloor.HitResult.ImpactNormal * -1.0f);
                                	}
                                
                                	UpdateComponentRotation();
                                }
                                
                                FVector UCharacterMovementComponent::GetComponentDesiredAxisZ() const
                                {
                                	if (IsMovingOnGround())
                                	{
                                		return CurrentFloor.HitResult.ImpactNormal;
                                	}
                                
                                	return GetGravityDirection(true) * -1.0f;
                                }
                                About changing the gravity of other actors, I didn't do anything about that, but I remember there were threads about that matter in these forums.
                                Sorry if this is a noobish question, but how do I now use that updated code?
                                At the moment I do a line trace from my character to the center of an object (in my case a sphere). I understand that I need to break the hit > get the normal > reverse it, but what do I do then? I've tried plugging that result into the Set Gravity Direction node but that's not giving the desired result. I read something about applying a rotation to the CapsuleComponent of the character?

                                I think you'd help out alot of people if you'd explain how to use this logic in blueprints.

                                Thanks in advance!

                                Comment

                                Working...
                                X