Hi guys,
I been stuck on this for several days now, and I get that error for anything that uses AttachTo:
collisionComp = CreateDefaultSubobject<USphereComponent>(TEXT("CollisonComp"));
RootComponent = collisionComp;
spellMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SpellMesh"));
spellMesh->AttachTo(RootComponent);
projectileMovementComp = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComp"));
projectileMovementComp->AttachTo(RootComponent);
I included Engine.h and even checked if attachto actually exsists for ustatic,uskeletal and projectilemovement and it does not seem to exist.
Mind you I never had this issue in 4.6.
Thank you,
Did you mean to use UStaticMeshComponent
instead?
Azarus
(Azarus)
March 27, 2015, 10:42pm
3
If you want to attach components:
In the constructor use AttachParent
SpringArm = ObjectInitializer.CreateDefaultSubobject<USpringArmComponent>(this, TEXT("SprintArm"));
SpringArm->AttachParent = CapsuleComponent;
Camera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
Camera->AttachParent = SpringArm;
Otherwise use AttachTo
If you want to attach actors to an another actor use:
AttachRootComponentToActor
or
AttachRootComponentTo
Also i think youāre creating the actor instances in the wrong way. Try spawning your actors with the SpawnActor call
UWorld* const World = GetWorld();
if (World)
{
World->SpawnActor<AActor>(AActor::StaticClass());
}
I hope it helps!
Cheers!
I fixed the typo, but the error still persist for both.
Iām not trying to spawn something in the world, Iām simply setting up the class for easy blueprint editing. I tried both and neither worked =/
Iām using 4.7.3 btw, you seem to be using something older.
So after a bit of looking around I finally fixed the issue, for some reason AttachTo still doesnāt exist, and AttachToRoot simply crashed the editor.
spellMesh->AttachParent = RootComponent;
Using AttachParent=root worked for me. Thanks for the help guys.
EDIT: AttachParent does not work after I rebuilt it a 2nd time. It now gives me the same error as the title.
1 Like
I had that issue beforeā¦but canāt remember why it was happening⦠are you including the correct headers?
Azarus
(Azarus)
March 28, 2015, 6:49am
8
That is the same code i postedā¦
Azarus
(Azarus)
March 28, 2015, 6:56am
9
The code is compatible with 4.7.3 as well so it is not the case.
what headers should i be including? i rebuilt this and now AttachParent is giving me the same stupid error: error C2039: āAttachParentā : is not a member of āUProjectileMovementComponentā
I restarted vs2013 and included that header, it fixed the issue for my mesh but not projectile component.
Edit: Iām trying AttachToRoot() for it, I have engine.h included in my main project file.
in your CPP file you should have
#include "GameFramework/ProjectileMovementComponent.h"
for your projectile
Also do you have
#include āEngine.hā
in your main project header? Not sure if that would help but it adds extra stuff
you should use āSetupAttachment()ā instead of āAttachTo()ā.
it works for me without any other changes (UE5).
1 Like
This worked for me. Thank you!
1 Like