Announcement

Collapse
No announcement yet.

How can I edit CharacterMovementComponent

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

    How can I edit CharacterMovementComponent

    I'm new to using c++ in Unreal.
    I'm trying to find out how I can edit the CharacterMovementComponent.cpp file.
    I've managed to adjust it and VS tells me the file is write only, so I overwrite it but adding code to the file does not work when testing the game.
    It's still using the unedited write protected CharacterMovementComponent most likely.

    How do I go about creating and using my own custom edited version of CharacterMovementComponent?

    #2
    Copy CharacterMovementComponent.h and CharacterMovementComponent.cpp to your own project, rename the class (and all references to that class name in your copied files) to something else like "MyCharacterMovementComponent" and then start editing it.

    If you want to edit CharacterMovementComponent.cpp directly, you should check out a copy of the UE4 sources from github, but that means you'll have to be using a custom build of UE4 and will therefore need to distribute it to anyone working on your project. The method above is much simpler.
    Last edited by drichardson; 02-04-2019, 03:02 PM.

    Comment


      #3
      Originally posted by drichardson View Post
      Copy CharacterMovementComponent.h and CharacterMovementComponent.cpp to your own project, rename the class (and all references to that class name in your copied files) to something else like "MyCharacterMovementComponent" and then start editing it.

      If you want to edit CharacterMovementComponent.cpp directly, you should check out a copy of the UE4 sources from github, but that means you'll have to be using a custom build of UE4 and will therefore need to distribute it to anyone working on your project. The method above is much simpler.
      Ok thanks! The problem is that I already have a character in my game with A LOT of blueprint code in it. How can I swap out the character movement component it uses for the custom one I want to make?

      Is there a way to get my own custom charactermovement component in my existing character or do I have to migrate all my code to a new custom character?
      If I have to migrate it will be hell, because the character is referenced in many existing blueprints as well, this will break all those blueprints. I really hope I can change the charactermovement component of my existing character.
      Last edited by WixZ; 02-04-2019, 03:13 PM.

      Comment


        #4
        Does this link about changing parent class in the blueprint help you out?

        Comment


          #5
          Originally posted by drichardson View Post
          Aha! I forgot about reparenting!

          This should work right? So basically I create my own character using my own custom version of charactermovement component and then I reparent my existing character to my own custom made character?

          Comment


            #6
            Yes, I think so. That assumes that your blueprint is currently an component blueprint (not an actor). I haven't done this a lot myself, so let me know how it goes.

            Comment


              #7
              That should be it. You might run into an old bug where your reparented blueprint won't recognize it's CDO, but that can be worked around by creating a new blueprint instead of reparenting the existing one. Hopefully you don't have to in this case!

              Comment


                #8
                Originally posted by Stefan Lundmark View Post
                That should be it. You might run into an old bug where your reparented blueprint won't recognize it's CDO, but that can be worked around by creating a new blueprint instead of reparenting the existing one. Hopefully you don't have to in this case!
                Hmmm, hopefully I don't have this issue as remaking the entire blueprint will be a lot of work. :/

                Comment


                  #9
                  Could someone maybe give me a hand? I'm trying to follow this tutorial:

                  https://wiki.unrealengine.com/Custom...ment_Component

                  But my knowledge of the c++ classes is too limited to understand what files need to be edited and what steps need to be taken in order to make it work.
                  Some guidance would be very appreciated!

                  For example, Am I right in assuming that the core classes which are under the Engine folder can't be edited? I've tried editing a file for testing purposes, but upon saving VS prompted me that it the file I was editing is write protected, it then suggested to overwrite the file, which I did which allowed me to edit and save the files. However, in-engine / in-game the added code seemed to have no effect. So it's probably still using the unedited version of the files outside of VS.

                  So as far as I understand it I have to create a custom character and a custom character movement component. Then override the parent functions of the initializer with a custom one which forces the custom character to use my custom movement component. Right?

                  But I don't really know how to structure the overrive function. Following the tutorial and replacing the placeholder component name with my own gives me errors.

                  EDIT1: I managed to succesfully reparent my character to my custom character without any issues (as far as I can see anyway).
                  Now onto step two, making the custom character use my custom movement component.
                  Last edited by WixZ; 02-05-2019, 06:17 AM.

                  Comment


                    #10
                    Ok I'm stuck. I can't seem to find how to make my custom character use my custom character movement component.
                    If someone could provide a step by step walkthrough on how to setup my custom character class to use my custom created charactermovement component that would be incredible!

                    Comment


                      #11
                      What behavior are you trying to change in the CharacterMovementComponent?
                      https://www.casualdistractiongames.com

                      Comment


                        #12
                        Originally posted by OptimisticMonkey View Post
                        What behavior are you trying to change in the CharacterMovementComponent?
                        We're trying to adjust the server - client correction logic because it's causing a very annoying jitter when standing on a moving base. In the game we are creating players are constantly standing on a big moving mesh. The mesh's location is being sent from the server to all connected clients. The clients then interpolate their own copy of the mesh to the server's retrieved transform. The problem here is that the players standing on the mesh have a slightly different transform from their server copies which causes the server to constantly correct between the client's location and it's own location. We want to adjust the logic in such a way that the server takes the client's moving base transform difference into account and basically nullifies the difference between the trasnform of the client's moving base and the server's moving base. With this we hope to eliminate or greatly reduce the server's correcting.

                        Comment

                        Working...
                        X