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"

Override Movement component in default 4.18 constructor

How do we create (override) the default character movement component using the default constructor on 4.18, instead of Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName))

Product Version: UE 4.18
Tags:
more ▼

asked Jan 11 '18 at 11:01 PM in C++ Programming

avatar image

huatson
8 5 7

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

1 answer: sort voted first

Hey there, i searched online and found this:

 In my pawn class, I create my custom movement component in my constructor
 
 PawnMovementComponent = CreateDefaultSubobject(TEXT("PawnMovement")); PawnMovementComponent->SetUpdatedComponent(CollisionComponent);
 
 and override this...
 
 virtual UPawnMovementComponent* GetMovementComponent() const override { return PawnMovementComponent; }

Worst case you can use the old FObjectInitializer

more ▼

answered Jan 12 '18 at 10:33 AM

avatar image

xlar8or
6k 163 130 305

avatar image huatson Jan 21 '18 at 12:01 AM

Thank you! That is exaclty what i need Works great.

avatar image xlar8or Jan 21 '18 at 12:08 AM

Good to know :)

avatar image 92Rob May 16 '18 at 03:26 PM

How would I then go about destroying the default movement component? Because when I do this, I now have 2 movement components on my character. And I can't seem to access the default one to destroy it become I have overriden GetMovementComponent()

avatar image 92Rob May 16 '18 at 03:28 PM

k I just found a solution. I call the base classess GetMovementComponent specifically :)

 ACharacter::GetMovementComponent()->DestroyComponent();
avatar image 92Rob May 16 '18 at 03:39 PM

Scrap that, gives strange results where I recompile an additional movement component gets added until I compile the BP.

(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