x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Make ACharacter Use Inherited UCharacterMovementCompenent

Hi, I made a Class that has UCharacterMovementComponent as it's parent, I did this so that I could override one of its functions to implement custom functionality like so:

 UCLASS()
 class MYMIRRORING_API USuperCharacterMovementComponent : public UCharacterMovementComponent
 {
     GENERATED_BODY()
 protected:
     virtual void PerformMovement(float DeltaTime) override;
 
 public:
     UPROPERTY(Category = "Character Movement: Mirror", EditAnywhere, BlueprintReadWrite)
     bool MirrorRootMotion;
     
     UPROPERTY(Category = "Character Movement: Mirror", EditAnywhere, BlueprintReadWrite)
         TEnumAsByte<EAxis::Type> MirrorAxis;
 
     UPROPERTY(Category = "Character Movement: Mirror", EditAnywhere, BlueprintReadWrite)
         TEnumAsByte<EAxis::Type> FlipAxis;
 };

But now I dont know how to specify to an ACharacter to have USuperCharacterMovementComponent instead of UCharacterMovementComponent, any help will be apreciated.

Product Version: UE 4.14
Tags:
more ▼

asked Mar 21 '17 at 11:26 PM in C++ Programming

avatar image

Hethger
13 3 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You need to use the FObjectInitializer passed to the constructor:

 UCLASS()
 class ANSWERHUB_API AMovementCharacter : public ACharacter
 {
     GENERATED_BODY()
 
 public:
     AMovementCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
     
 };
 
 AMovementCharacter::AMovementCharacter(const FObjectInitializer& ObjectInitializer /*= FObjectInitializer::Get()*/)
     : Super(ObjectInitializer.SetDefaultSubobjectClass<UMyCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
 {
 }

Then your characters will have the custom movement component:

alt text

more ▼

answered Mar 22 '17 at 06:58 AM

avatar image

Matthias Hölzl
416 13 6 19

avatar image Hethger Mar 22 '17 at 12:15 PM

Nice! Thanks a lot.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question