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"

Initialize WheeledVehicleMovementComponent

Hello!

For the project I am currently working on I need wheeled vehicles. I am not using the WheeledVehicle class because I want all of my different vehicle types (cars, planes, helis etc) to derive from the same base class.

I noticed that UWheeledVehicleMovementComponent is abstract and cannot be initialized with CreateDefaultSubobject, so I tried CreateAbstractDefaultSubobject. It allows the code compile and start up the editor, however I do not see the component on child Blueprints (this is not a problem of the blueprint accessability) and in the defaults tab the component name is listed with some kind of string value which is set to "None".

So does anyone know how to initialize an abstract component?

Thanks!

PS.: I wanted to have a look at the WheeledVehicle constructor but it isn't visible in the API documentation.

Product Version: Not Selected
Tags:
more ▼

asked Feb 15 '15 at 08:55 PM in C++ Programming

avatar image

Fluppi393
457 36 33 54

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

1 answer: sort voted first

AWheeledVehicle constructor:

 FName AWheeledVehicle::VehicleMovementComponentName(TEXT("MovementComp"));
     
 FName AWheeledVehicle::VehicleMeshComponentName(TEXT("VehicleMesh"));
     
 AWheeledVehicle::AWheeledVehicle(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
 {
   Mesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, VehicleMeshComponentName);
   Mesh->SetCollisionProfileName(UCollisionProfile::Vehicle_ProfileName);
   Mesh->BodyInstance.bSimulatePhysics = true;
   Mesh->BodyInstance.bNotifyRigidBodyCollision = true;
   Mesh->BodyInstance.bUseCCD = true;
   Mesh->bBlendPhysics = true;
   Mesh->bGenerateOverlapEvents = true;
   Mesh->bCanEverAffectNavigation = false;
   RootComponent = Mesh;
 
   VehicleMovement = ObjectInitializer.CreateDefaultSubobject<UWheeledVehicleMovementComponent, UWheeledVehicleMovementComponent4W>(this, VehicleMovementComponentName);
   VehicleMovement->SetIsReplicated(true); // Enable replication by default
   VehicleMovement->UpdatedComponent = Mesh;
 }

UWheeledVehicleMovementComponent4W declaration:

 UCLASS()
 class ENGINE_API UWheeledVehicleMovementComponent4W : public UWheeledVehicleMovementComponent

There are a lot of code inside UWheeledVehicleMovementComponent4W. You can download all this files from GitHub.

more ▼

answered Feb 16 '15 at 04:28 PM

avatar image

wmask
81 3 8 11

avatar image Fluppi393 Feb 16 '15 at 05:24 PM

Thanks wamsk! I know that I could have downloaded the source code but I didn't want to do that just for on single line of code...

For whoever is also interested in the solution, here is how it should look like in the header and code file:

 UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = Components)
             TSubobjectPtr<UWheeledVehicleMovementComponent> VehicleMovement;


 VehicleMovement = PCIP.CreateDefaultSubobject<UWheeledVehicleMovementComponent, UWheeledVehicleMovementComponent4W>(this, TEXT("VehicleMovement"));
avatar image wmask Feb 16 '15 at 05:39 PM

Code from header:

 UPROPERTY(Category = Vehicle, VisibleDefaultsOnly, BlueprintReadOnly)
 class UWheeledVehicleMovementComponent* VehicleMovement;
(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