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"

USplineComponent not setting as the RootComponent of th Actor

I am creating Pipes Generating tool based on USplineComponent. For that I have to set the USplineComponent as the Root Component of my Actor based GenPipe class. I have tried this:

 //GenPipe.cpp
 AGenPipe::AGenPipe()   //..The Constuctor
 {
    splineComponent = CreateDefaultSubobject<USplineComponent>(TEXT("Spline Component"));
    RootComponent = splineComponent;   //..Problematic Assignment
 }
 

The splineComponent is declared in like this:

 //somewhere in GenPipe.h
 private:
    class USplineComponent* splineComponent;

But when I compile, It gives me compilation error:

 //Error after compilation
 
 error C2440: '=': cannot convert from 'USplineComponent *' to 'USceneComponent * '
 note:Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast.
 

Any help will be appreciated.

Product Version: UE 4.16
Tags:
more ▼

asked Jul 14 '17 at 09:07 PM in C++ Programming

avatar image

rahulverma192
3 2 3

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

2 answers: sort voted first

[Solved]

I Solved the problem by myself. I was not including header for spline component.

 #include <Runtime/Engine/Classes/Components/SplineComponent.h>

After including the header, It worked.

more ▼

answered Jul 15 '17 at 09:08 AM

avatar image

rahulverma192
3 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
 #include "Components/SplineComponent.h"
 
 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = SomeCategory, meta = (AllowPrivateAccess = "true"))
 class USplineComponent* splineComponent;
 
 SetRootComponent(splineComponent);
more ▼

answered Jul 14 '17 at 09:29 PM

avatar image

Nachtmahr
7k 143 28 172

avatar image rahulverma192 Jul 15 '17 at 09:01 AM

I Tried the solution but getting same kind of errors:

 error C2664: 'bool AActor::SetRootComponent(USceneComponent *)': cannot convert argument 1 from 'USplineComponent *' to 'USceneComponent *'
 
     note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
 

(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