Announcement

Collapse
No announcement yet.

Adding custom movement component

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

    Adding custom movement component

    I've followed Rama's tutorial here

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

    But now that the component is working, I cant actually move at all. The code below definitely runs and displays stuff on the screen.

    Code:
    //Tick Comp
    void UpXCharMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
    {
    	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
    
    	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Component definitely called parent!"));
    }
    I noticed that when my custom movement component is working, my character class no longer has a "Character Movement Component". I'm pretty sure the is is the cause, but I cant understand why the controller disappears.

    I found this in the log but I cant figure out what it means.

    Code:
    LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
    LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
    LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.

    #2
    It seems others have the same problems. All are on the 4.2 update.

    https://answers.unrealengine.com/que...component.html

    No one has an answer yet. Shooter game works in 4.2 using the same code so I have no idea what is going on

    Comment


      #3
      Could anyone from epic comment on this? Not being able to customise the movement system is driving me crazy. I'm using the 4.2.1 codebase.

      Steps to reproduce

      Set up a new c++ FPS project
      Add a new code file subclass of CharacterMovementComponent
      Change your projects character.cpp class as follows

      Code:
      AProjCharacter::AProjCharacter(const class FPostConstructInitializeProperties& PCIP)
      	: Super(PCIP.SetDefaultSubobjectClass<UProjCharacterMovement>(ACharacter::CharacterMovementComponentName))
      Watch as every call to GetCharacter()->CharacterMovement; returns NULL

      A good example to breakpoint is APlayerController:BeginPlayingState().
      Last edited by GeekyPayback; 07-10-2014, 02:39 AM.

      Comment


        #4
        So I installed the engine from github and started debugging

        [code]
        AProjectXCharacter::AProjectXCharacter(const class FPostConstructInitializeProperties& PCIP)
        : Super(PCIP)

        These two are after InternalConstructor and ConstructObject (respectively) have finished running
        Click image for larger version

Name:	default-post-internal-constructor.PNG
Views:	1
Size:	51.7 KB
ID:	1052542
        Click image for larger version

Name:	default-post-construct-object.PNG
Views:	1
Size:	58.8 KB
ID:	1052543

        The CharacterMovement contains a value in both Autos windows

        Then the same again where the only change in the entire code base

        Code:
        AProjectXCharacter::AProjectXCharacter(const class FPostConstructInitializeProperties& PCIP)
        	: Super(PCIP.SetDefaultSubobjectClass<UProjectXCharacterMovement>(ACharacter::CharacterMovementComponentName)) //: Super(PCIP)
        Click image for larger version

Name:	PX-post-internal-constructor.PNG
Views:	1
Size:	53.1 KB
ID:	1052544
        Click image for larger version

Name:	PX-post-construct-object.PNG
Views:	1
Size:	60.2 KB
ID:	1052545

        You can see that the internal constructor correctly created the movement component but it gets lost when returning it all to the SpawnActor function.

        I'm now completely at the limit of my knowledge. Is this a bug in the engine or have I done something wrong?

        Comment


          #5
          I'm guessing that you are using a Blueprint as your actual character type? I ran into the same issue with 4.2, where I have a Blueprint of my custom Character, using the default CharacterMovementComponent, and when I updated my Character to use a custom CharacterMovementComponent, the existing Blueprint didn't work correctly anymore.

          My solution was to create a new Blueprint, exactly like the original, after implementing the new CharacterMovementComponent.

          I saw some discussion about this elsewhere, and IIRC, someone already submitted a patch to the UnrealEngine project on GitHub to address it - so it shouldn't be a problem in the next release.

          Comment


            #6
            Thank you for registering and making your first post on this forum a solution to my problem. I love you (in a purely platonic manner).

            I've updated all the references I've found to reflect this knowledge.

            Comment


              #7
              Originally posted by GeekyPayback View Post
              Code:
              LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
              LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
              LogLinker:Error: Failed import: class 'CharacterMovementComponent' name 'CharMoveComp' outer 'Default__MyCharacter_C'. There is another object (of 'pXCharMovementComponent' class) at the path.
              This (as well the issue with not being able to set the custom component class) has been fixed here.
              Lead Core Programmer, UE4, Epic Games

              Comment


                #8
                Originally posted by robert.manuszewski View Post
                This (as well the issue with not being able to set the custom component class) has been fixed here.
                Thank you for fixing this Robert!

                Thanks for sharing a solution Starcraft Fan!

                Yaaay!



                Rama
                Last edited by Rama; 07-14-2014, 12:27 PM.
                100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

                UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

                Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

                Comment


                  #9
                  Greetings. I have exactly the same issue with my movement component, but the following comment - "This (as well the issue with not being able to set the custom component class) has been fixed here." - can' t help me as the link behind it is not available anymore...

                  Could you tell me what to do?

                  Comment


                    #10
                    The link goes to the relevant line change in github. You need to be signed in and allowed to see the unrealengine source to see it. If you really are falling foul of this bug, the solution is to upgrade to unrealengine 4.3 or higher. Sorry thats probably not the answer you are looking for, but this is a 2 year old thread after all.

                    You are probably better off starting a new thread, listing out your own error messages and issues (like I did above) as your problem wont be the one discussed above.

                    Comment


                      #11
                      I am running in the exact same problem. I was using a custom CharacterMovementComponent. As I no longer require it, I have removed it.
                      Now GetCharacterMovement() returns nullptr and I am no longer able to control the character in-game.
                      My setup: Custom C++ Character -> Blueprint Character based on C++.
                      Version 4.17.2
                      During looking for a solution I noticed that suddenly another completely unrelated Blueprint did no longer compile due to asset references. I never touched the assets.
                      Last edited by Mellnik; 10-01-2017, 10:44 AM.

                      Comment


                        #12
                        Originally posted by Mellnik View Post
                        I am running in the exact same problem. I was using a custom CharacterMovementComponent. As I no longer require it, I have removed it.
                        Now GetCharacterMovement() returns nullptr and I am no longer able to control the character in-game.
                        My setup: Custom C++ Character -> Blueprint Character based on C++.
                        Version 4.17.2
                        During looking for a solution I noticed that suddenly another completely unrelated Blueprint did no longer compile due to asset references. I never touched the assets.
                        Did you try to delete your character blueprint and recreate it as stated above? Blueprints simetimes cause problems when deleting, adding, renaming components etc.

                        Comment


                          #13
                          Yes, I recreated the entire blueprint. Took me an hour to port everything over.
                          It should work more reliable in my opinion. This can be very frustrating.

                          Comment


                            #14
                            I have same problem. It occur 100% when I reparent my own ACharacterEx class to ACharacter.
                            I'm using UE 4.17.2

                            Comment


                              #15
                              If you re-created the Blueprint and you have the problem still, then the issue is likely still in the code. Blueprints can hold on to UPROPERTY()'s even if you remove them from the C++ class. It's fine to add them, but taking them away or renaming objects often means you need to recreate the Blueprint or you might face all kinds of random issues.

                              The same is true for re-parenting. I would suggest checking the C++ again, then recreating your Blueprint.

                              Comment

                              Working...
                              X